11832Swollman/* 21832Swollman * Network lock manager protocol definition 31832Swollman * Copyright (C) 1986 Sun Microsystems, Inc. 41832Swollman * 51832Swollman * protocol used between local lock manager and remote lock manager 61832Swollman */ 71832Swollman 81832Swollman#ifdef RPC_HDR 91832Swollman%#define LM_MAXSTRLEN 1024 101832Swollman%#define MAXNAMELEN LM_MAXSTRLEN+1 111832Swollman#else 1274462Salfred%#include <sys/cdefs.h> 131832Swollman%#ifndef lint 1474462Salfred%/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/ 1574462Salfred%/*static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ 1674462Salfred%__RCSID("$NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $"); 171832Swollman%#endif /* not lint */ 18114629Sobrien%__FBSDID("$FreeBSD$"); 191832Swollman#endif 201832Swollman 211832Swollman/* 221832Swollman * status of a call to the lock manager 231832Swollman */ 241832Swollmanenum nlm_stats { 251832Swollman nlm_granted = 0, 261832Swollman nlm_denied = 1, 271832Swollman nlm_denied_nolocks = 2, 281832Swollman nlm_blocked = 3, 2975631Salfred nlm_denied_grace_period = 4, 3075631Salfred nlm_deadlck = 5 311832Swollman}; 321832Swollman 331832Swollmanstruct nlm_holder { 341832Swollman bool exclusive; 351832Swollman int svid; 361832Swollman netobj oh; 371832Swollman unsigned l_offset; 381832Swollman unsigned l_len; 391832Swollman}; 401832Swollman 411832Swollmanunion nlm_testrply switch (nlm_stats stat) { 421832Swollman case nlm_denied: 431832Swollman struct nlm_holder holder; 441832Swollman default: 451832Swollman void; 461832Swollman}; 471832Swollman 481832Swollmanstruct nlm_stat { 491832Swollman nlm_stats stat; 501832Swollman}; 511832Swollman 521832Swollmanstruct nlm_res { 531832Swollman netobj cookie; 541832Swollman nlm_stat stat; 551832Swollman}; 561832Swollman 571832Swollmanstruct nlm_testres { 581832Swollman netobj cookie; 591832Swollman nlm_testrply stat; 601832Swollman}; 611832Swollman 621832Swollmanstruct nlm_lock { 631832Swollman string caller_name<LM_MAXSTRLEN>; 641832Swollman netobj fh; /* identify a file */ 651832Swollman netobj oh; /* identify owner of a lock */ 661832Swollman int svid; /* generated from pid for svid */ 671832Swollman unsigned l_offset; 681832Swollman unsigned l_len; 691832Swollman}; 701832Swollman 711832Swollmanstruct nlm_lockargs { 721832Swollman netobj cookie; 731832Swollman bool block; 741832Swollman bool exclusive; 751832Swollman struct nlm_lock alock; 761832Swollman bool reclaim; /* used for recovering locks */ 771832Swollman int state; /* specify local status monitor state */ 781832Swollman}; 791832Swollman 801832Swollmanstruct nlm_cancargs { 8174462Salfred netobj cookie; 821832Swollman bool block; 831832Swollman bool exclusive; 841832Swollman struct nlm_lock alock; 851832Swollman}; 861832Swollman 871832Swollmanstruct nlm_testargs { 8874462Salfred netobj cookie; 891832Swollman bool exclusive; 901832Swollman struct nlm_lock alock; 911832Swollman}; 921832Swollman 931832Swollmanstruct nlm_unlockargs { 9474462Salfred netobj cookie; 951832Swollman struct nlm_lock alock; 961832Swollman}; 971832Swollman 981832Swollman 991832Swollman#ifdef RPC_HDR 1001832Swollman%/* 1011832Swollman% * The following enums are actually bit encoded for efficient 1021832Swollman% * boolean algebra.... DON'T change them..... 1031832Swollman% */ 1041832Swollman#endif 1051832Swollmanenum fsh_mode { 1061832Swollman fsm_DN = 0, /* deny none */ 1071832Swollman fsm_DR = 1, /* deny read */ 1081832Swollman fsm_DW = 2, /* deny write */ 1091832Swollman fsm_DRW = 3 /* deny read/write */ 1101832Swollman}; 1111832Swollman 1121832Swollmanenum fsh_access { 1131832Swollman fsa_NONE = 0, /* for completeness */ 1141832Swollman fsa_R = 1, /* read only */ 1151832Swollman fsa_W = 2, /* write only */ 1161832Swollman fsa_RW = 3 /* read/write */ 1171832Swollman}; 1181832Swollman 1191832Swollmanstruct nlm_share { 1201832Swollman string caller_name<LM_MAXSTRLEN>; 1211832Swollman netobj fh; 1221832Swollman netobj oh; 1231832Swollman fsh_mode mode; 1241832Swollman fsh_access access; 1251832Swollman}; 1261832Swollman 1271832Swollmanstruct nlm_shareargs { 1281832Swollman netobj cookie; 1291832Swollman nlm_share share; 1301832Swollman bool reclaim; 1311832Swollman}; 1321832Swollman 1331832Swollmanstruct nlm_shareres { 1341832Swollman netobj cookie; 1351832Swollman nlm_stats stat; 1361832Swollman int sequence; 1371832Swollman}; 1381832Swollman 1391832Swollmanstruct nlm_notify { 1401832Swollman string name<MAXNAMELEN>; 1411832Swollman long state; 1421832Swollman}; 1431832Swollman 14474462Salfred#ifdef RPC_HDR 14574462Salfred%/* definitions for NLM version 4 */ 14674462Salfred#endif 14774462Salfredenum nlm4_stats { 14874462Salfred nlm4_granted = 0, 14974462Salfred nlm4_denied = 1, 15075631Salfred nlm4_denied_nolocks = 2, 15174462Salfred nlm4_blocked = 3, 15274462Salfred nlm4_denied_grace_period = 4, 15374462Salfred nlm4_deadlck = 5, 15474462Salfred nlm4_rofs = 6, 15574462Salfred nlm4_stale_fh = 7, 15674462Salfred nlm4_fbig = 8, 15774462Salfred nlm4_failed = 9 15874462Salfred}; 15974462Salfred 16074462Salfredstruct nlm4_stat { 16174462Salfred nlm4_stats stat; 16274462Salfred}; 16374462Salfred 16474462Salfredstruct nlm4_holder { 16574462Salfred bool exclusive; 16674462Salfred u_int32_t svid; 16774462Salfred netobj oh; 16874462Salfred u_int64_t l_offset; 16974462Salfred u_int64_t l_len; 17074462Salfred}; 17174462Salfred 17274462Salfredstruct nlm4_lock { 17374462Salfred string caller_name<MAXNAMELEN>; 17474462Salfred netobj fh; 17574462Salfred netobj oh; 17674462Salfred u_int32_t svid; 17774462Salfred u_int64_t l_offset; 17874462Salfred u_int64_t l_len; 17974462Salfred}; 18074462Salfred 18174462Salfredstruct nlm4_share { 18274462Salfred string caller_name<MAXNAMELEN>; 18374462Salfred netobj fh; 18474462Salfred netobj oh; 18574462Salfred fsh_mode mode; 18674462Salfred fsh_access access; 18774462Salfred}; 18874462Salfred 18974462Salfredunion nlm4_testrply switch (nlm4_stats stat) { 19074462Salfred case nlm_denied: 19174462Salfred struct nlm4_holder holder; 19274462Salfred default: 19374462Salfred void; 19474462Salfred}; 19574462Salfred 19674462Salfredstruct nlm4_testres { 19774462Salfred netobj cookie; 19874462Salfred nlm4_testrply stat; 19974462Salfred}; 20074462Salfred 20174462Salfredstruct nlm4_testargs { 20274462Salfred netobj cookie; 20374462Salfred bool exclusive; 20474462Salfred struct nlm4_lock alock; 20574462Salfred}; 20674462Salfred 20774462Salfredstruct nlm4_res { 20874462Salfred netobj cookie; 20974462Salfred nlm4_stat stat; 21074462Salfred}; 21174462Salfred 21274462Salfredstruct nlm4_lockargs { 21374462Salfred netobj cookie; 21474462Salfred bool block; 21574462Salfred bool exclusive; 21674462Salfred struct nlm4_lock alock; 21774462Salfred bool reclaim; /* used for recovering locks */ 21874462Salfred int state; /* specify local status monitor state */ 21974462Salfred}; 22074462Salfred 22174462Salfredstruct nlm4_cancargs { 22274462Salfred netobj cookie; 22374462Salfred bool block; 22474462Salfred bool exclusive; 22574462Salfred struct nlm4_lock alock; 22674462Salfred}; 22774462Salfred 22874462Salfredstruct nlm4_unlockargs { 22974462Salfred netobj cookie; 23074462Salfred struct nlm4_lock alock; 23174462Salfred}; 23274462Salfred 23374462Salfredstruct nlm4_shareargs { 23474462Salfred netobj cookie; 23574462Salfred nlm4_share share; 23674462Salfred bool reclaim; 23774462Salfred}; 23874462Salfred 23974462Salfredstruct nlm4_shareres { 24074462Salfred netobj cookie; 24174462Salfred nlm4_stats stat; 24274462Salfred int sequence; 24374462Salfred}; 24474462Salfred 2451832Swollman/* 24674462Salfred * argument for the procedure called by rpc.statd when a monitored host 24774462Salfred * status change. 24874462Salfred * XXX assumes LM_MAXSTRLEN == SM_MAXSTRLEN 24974462Salfred */ 25074462Salfredstruct nlm_sm_status { 25174462Salfred string mon_name<LM_MAXSTRLEN>; /* name of host */ 25274462Salfred int state; /* new state */ 25374462Salfred opaque priv[16]; /* private data */ 25474462Salfred}; 25574462Salfred 25675631Salfredstruct nlm4_notify { 25775631Salfred string name<MAXNAMELEN>; 25875631Salfred int32_t state; 25975631Salfred}; 26075631Salfred 26174462Salfred/* 2621832Swollman * Over-the-wire protocol used between the network lock managers 2631832Swollman */ 2641832Swollman 2651832Swollmanprogram NLM_PROG { 26675631Salfred 26774462Salfred version NLM_SM { 26874462Salfred void NLM_SM_NOTIFY(struct nlm_sm_status) = 1; 26974462Salfred } = 0; 27074462Salfred 2711832Swollman version NLM_VERS { 2721832Swollman 2731832Swollman nlm_testres NLM_TEST(struct nlm_testargs) = 1; 2741832Swollman 2751832Swollman nlm_res NLM_LOCK(struct nlm_lockargs) = 2; 2761832Swollman 2771832Swollman nlm_res NLM_CANCEL(struct nlm_cancargs) = 3; 2781832Swollman nlm_res NLM_UNLOCK(struct nlm_unlockargs) = 4; 2791832Swollman 2801832Swollman /* 2811832Swollman * remote lock manager call-back to grant lock 2821832Swollman */ 2831832Swollman nlm_res NLM_GRANTED(struct nlm_testargs)= 5; 2841832Swollman /* 2851832Swollman * message passing style of requesting lock 2861832Swollman */ 2871832Swollman void NLM_TEST_MSG(struct nlm_testargs) = 6; 2881832Swollman void NLM_LOCK_MSG(struct nlm_lockargs) = 7; 2891832Swollman void NLM_CANCEL_MSG(struct nlm_cancargs) =8; 2901832Swollman void NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9; 2911832Swollman void NLM_GRANTED_MSG(struct nlm_testargs) = 10; 2921832Swollman void NLM_TEST_RES(nlm_testres) = 11; 2931832Swollman void NLM_LOCK_RES(nlm_res) = 12; 2941832Swollman void NLM_CANCEL_RES(nlm_res) = 13; 2951832Swollman void NLM_UNLOCK_RES(nlm_res) = 14; 2961832Swollman void NLM_GRANTED_RES(nlm_res) = 15; 2971832Swollman } = 1; 2981832Swollman 2991832Swollman version NLM_VERSX { 3001832Swollman nlm_shareres NLM_SHARE(nlm_shareargs) = 20; 3011832Swollman nlm_shareres NLM_UNSHARE(nlm_shareargs) = 21; 3021832Swollman nlm_res NLM_NM_LOCK(nlm_lockargs) = 22; 3031832Swollman void NLM_FREE_ALL(nlm_notify) = 23; 3041832Swollman } = 3; 3051832Swollman 30674462Salfred version NLM_VERS4 { 30774462Salfred nlm4_testres NLM4_TEST(nlm4_testargs) = 1; 30874462Salfred nlm4_res NLM4_LOCK(nlm4_lockargs) = 2; 30974462Salfred nlm4_res NLM4_CANCEL(nlm4_cancargs) = 3; 31074462Salfred nlm4_res NLM4_UNLOCK(nlm4_unlockargs) = 4; 31174462Salfred nlm4_res NLM4_GRANTED(nlm4_testargs) = 5; 31274462Salfred void NLM4_TEST_MSG(nlm4_testargs) = 6; 31374462Salfred void NLM4_LOCK_MSG(nlm4_lockargs) = 7; 31474462Salfred void NLM4_CANCEL_MSG(nlm4_cancargs) = 8; 31574462Salfred void NLM4_UNLOCK_MSG(nlm4_unlockargs) = 9; 31674462Salfred void NLM4_GRANTED_MSG(nlm4_testargs) = 10; 31774462Salfred void NLM4_TEST_RES(nlm4_testres) = 11; 31874462Salfred void NLM4_LOCK_RES(nlm4_res) = 12; 31974462Salfred void NLM4_CANCEL_RES(nlm4_res) = 13; 32074462Salfred void NLM4_UNLOCK_RES(nlm4_res) = 14; 32174462Salfred void NLM4_GRANTED_RES(nlm4_res) = 15; 32274462Salfred nlm4_shareres NLM4_SHARE(nlm4_shareargs) = 20; 32374462Salfred nlm4_shareres NLM4_UNSHARE(nlm4_shareargs) = 21; 32474462Salfred nlm4_res NLM4_NM_LOCK(nlm4_lockargs) = 22; 32575631Salfred void NLM4_FREE_ALL(nlm4_notify) = 23; 32674462Salfred } = 4; 3271832Swollman} = 100021; 328