7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright (c) 1991, 1998, 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
25 */
26
27 #include <sys/types.h>
28 #include <setjmp.h>
29 #include <string.h>
30
31 #ifdef notdef
32 #include <rpc/xdr.h>
33 #include <rpc/auth.h>
34 #include <rpc/rpc_msg.h>
35 #endif /* notdef */
36 #include <rpcsvc/nlm_prot.h>
37 #include "snoop.h"
38
39 extern char *dlc_header;
40 extern jmp_buf xdr_err;
41
42 extern void check_retransmit();
43 static void interpret_nlm_1();
44 static void interpret_nlm_3();
45 static void interpret_nlm_4();
46 static char *nameof_access();
801 char *line;
802 char *pl;
803 ulong_t i;
804
805 if (proc < 0 || proc > MAXPROC_4)
806 return;
807
808 if (flags & F_SUM) {
809 if (setjmp(xdr_err)) {
810 return;
811 }
812
813 line = get_sum_line();
814
815 if (type == CALL) {
816 (void) sprintf(line,
817 "NLM C %s",
818 procnames_short_4[proc]);
819 line += strlen(line);
820 switch (proc) {
821 case NLMPROC4_TEST:
822 case NLMPROC4_GRANTED:
823 case NLMPROC4_TEST_MSG:
824 case NLMPROC4_GRANTED_MSG:
825 /* testargs */
826 (void) strcat(line, sum_netobj("OH"));
827 (void) getxdr_bool(); /* Excl */
828 (void) strcat(line, sum_lock4());
829 break;
830 case NLMPROC4_LOCK:
831 case NLMPROC4_LOCK_MSG:
832 /* lockargs */
833 (void) strcat(line, sum_netobj("OH"));
834 (void) getxdr_bool(); /* Block */
835 (void) getxdr_bool(); /* Excl */
836 (void) strcat(line, sum_lock4());
837 /* ignore reclaim, state fields */
838 break;
839 case NLMPROC4_CANCEL:
840 case NLMPROC4_CANCEL_MSG:
841 /* cancargs */
842 (void) strcat(line, sum_netobj("OH"));
843 (void) getxdr_bool(); /* Block */
844 (void) getxdr_bool(); /* Excl */
845 (void) strcat(line, sum_lock4());
846 break;
847 case NLMPROC4_UNLOCK:
848 case NLMPROC4_UNLOCK_MSG:
849 /* unlockargs */
850 (void) strcat(line, sum_netobj("OH"));
851 (void) strcat(line, sum_lock4());
852 break;
853 case NLMPROC4_TEST_RES:
854 /* testres */
855 (void) strcat(line, sum_netobj("OH"));
856 (void) strcat(line, " ");
857 (void) strcat(line,
858 nameof_stat4(getxdr_u_long()));
859 break;
860 case NLMPROC4_LOCK_RES:
861 case NLMPROC4_CANCEL_RES:
862 case NLMPROC4_UNLOCK_RES:
863 case NLMPROC4_GRANTED_RES:
864 /* res */
865 (void) strcat(line, sum_netobj("OH"));
866 (void) strcat(line, " ");
867 (void) strcat(line,
868 nameof_stat4(getxdr_u_long()));
869 break;
870 case NLMPROC4_SHARE:
871 case NLMPROC4_UNSHARE:
872 (void) strcat(line, sum_netobj("OH"));
873 (void) strcat(line, sum_share());
874 break;
875 case NLMPROC4_NM_LOCK:
876 /* lockargs */
877 skip_netobj(); /* Cookie */
878 (void) getxdr_bool(); /* Block */
879 (void) getxdr_bool(); /* Excl */
880 (void) strcat(line, sum_lock4());
881 /* skip reclaim & state fields */
882 break;
883 case NLMPROC4_FREE_ALL:
884 (void) sprintf(line,
885 " %s", sum_notify());
886 break;
887 }
888 check_retransmit(line, (ulong_t)xid);
889 } else {
890 (void) sprintf(line, "NLM R %s",
891 procnames_short_4[proc]);
892 line += strlen(line);
893 switch (proc) {
894 case NLMPROC4_TEST:
895 /* testres */
896 (void) strcat(line, sum_netobj("OH"));
897 (void) strcat(line, " ");
898 (void) strcat(line,
899 nameof_stat4(getxdr_u_long()));
900 break;
901 case NLMPROC4_LOCK:
902 case NLMPROC4_CANCEL:
903 case NLMPROC4_UNLOCK:
904 case NLMPROC4_GRANTED:
905 case NLMPROC4_NM_LOCK:
906 /* res */
907 (void) strcat(line, sum_netobj("OH"));
908 (void) strcat(line, " ");
909 (void) strcat(line,
910 nameof_stat4(getxdr_u_long()));
911 break;
912 case NLMPROC4_SHARE:
913 case NLMPROC4_UNSHARE:
914 /* shareres */
915 pl = sum_netobj("OH");
916 i = getxdr_u_long();
917 sprintf(line, "%s %s %ld",
918 pl, nameof_stat4(i), getxdr_long());
919 break;
920 case NLMPROC4_FREE_ALL:
921 break;
922 }
923 }
924 }
925
926 if (flags & F_DTAIL) {
927 show_header("NLM: ", "Network Lock Manager", len);
928 show_space();
929 if (setjmp(xdr_err)) {
930 return;
931 }
932 (void) sprintf(get_line(0, 0),
933 "Proc = %d (%s)",
934 proc, procnames_long_4[proc]);
935 if (type == CALL) {
936 switch (proc) {
937 case NLMPROC4_TEST:
938 case NLMPROC4_GRANTED:
939 case NLMPROC4_TEST_MSG:
940 case NLMPROC4_GRANTED_MSG:
941 show_testargs4();
942 break;
943 case NLMPROC4_LOCK:
944 case NLMPROC4_LOCK_MSG:
945 case NLMPROC4_NM_LOCK:
946 show_lockargs4();
947 break;
948 case NLMPROC4_CANCEL:
949 case NLMPROC4_CANCEL_MSG:
950 show_cancargs4();
951 break;
952 case NLMPROC4_UNLOCK:
953 case NLMPROC4_UNLOCK_MSG:
954 show_unlockargs4();
955 break;
956 case NLMPROC4_TEST_RES:
957 show_testres4();
958 break;
959 case NLMPROC4_LOCK_RES:
960 case NLMPROC4_CANCEL_RES:
961 case NLMPROC4_UNLOCK_RES:
962 case NLMPROC4_GRANTED_RES:
963 show_res4();
964 break;
965 case NLMPROC4_SHARE:
966 case NLMPROC4_UNSHARE:
967 show_shareargs();
968 break;
969 case NLMPROC4_FREE_ALL:
970 show_notify();
971 break;
972 }
973 } else {
974 switch (proc) {
975 case NLMPROC4_TEST:
976 show_testres4();
977 break;
978 case NLMPROC4_LOCK:
979 case NLMPROC4_CANCEL:
980 case NLMPROC4_UNLOCK:
981 case NLMPROC4_GRANTED:
982 case NLM_NM_LOCK:
983 show_res4();
984 break;
985 case NLMPROC4_TEST_MSG:
986 case NLMPROC4_LOCK_MSG:
987 case NLMPROC4_CANCEL_MSG:
988 case NLMPROC4_UNLOCK_MSG:
989 case NLMPROC4_GRANTED_MSG:
990 case NLMPROC4_TEST_RES:
991 case NLMPROC4_LOCK_RES:
992 case NLMPROC4_CANCEL_RES:
993 case NLMPROC4_UNLOCK_RES:
994 case NLMPROC4_GRANTED_RES:
995 break;
996 case NLM_SHARE:
997 case NLM_UNSHARE:
998 show_shareres4();
999 break;
1000 case NLM_FREE_ALL:
1001 break;
1002 }
1003 }
1004 show_trailer();
1005 }
1006 }
1007
1008 static char *
1009 sum_lock4()
1010 {
1011 static char buff[LM_MAXSTRLEN + 1];
1012 char *cp = buff;
1013 long id;
1014 u_longlong_t off, len;
1065 static void
1066 show_testargs4()
1067 {
1068 show_netobj("Cookie = %s");
1069 showxdr_bool("Exclusive = %s");
1070 show_lock4();
1071 }
1072
1073 static void
1074 show_res4()
1075 {
1076 show_netobj("Cookie = %s");
1077 (void) show_stat4();
1078 }
1079
1080 static char *
1081 nameof_stat4(s)
1082 ulong_t s;
1083 {
1084 switch ((enum nlm4_stats) s) {
1085 case NLM4_GRANTED: return ("granted");
1086 case NLM4_DENIED: return ("denied");
1087 case NLM4_DENIED_NOLOCKS:return ("denied (no locks)");
1088 case NLM4_BLOCKED: return ("blocked");
1089 case NLM4_DENIED_GRACE_PERIOD: return ("denied (grace period)");
1090 case NLM4_DEADLCK: return ("deadlock");
1091 case NLM4_ROFS: return ("read-only fs");
1092 case NLM4_STALE_FH: return ("stale fh");
1093 case NLM4_FBIG: return ("file too big");
1094 case NLM4_FAILED: return ("failed");
1095 default: return ("?");
1096 }
1097 }
1098
1099 static enum nlm4_stats
1100 show_stat4()
1101 {
1102 enum nlm4_stats s;
1103
1104 s = (enum nlm4_stats) getxdr_u_long();
1105 (void) sprintf(get_line(0, 0),
1106 "Status = %d (%s)",
1107 s, nameof_stat4((ulong_t)s));
1108
1109 return (s);
1110 }
1111
1112 static void
1113 show_testres4()
1114 {
|
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright (c) 1991, 1998, 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
25 */
26
27 /*
28 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
29 * Copyright (c) 2012 by Delphix. All rights reserved.
30 */
31
32 #include <sys/types.h>
33 #include <setjmp.h>
34 #include <string.h>
35
36 #ifdef notdef
37 #include <rpc/xdr.h>
38 #include <rpc/auth.h>
39 #include <rpc/rpc_msg.h>
40 #endif /* notdef */
41 #include <rpcsvc/nlm_prot.h>
42 #include "snoop.h"
43
44 extern char *dlc_header;
45 extern jmp_buf xdr_err;
46
47 extern void check_retransmit();
48 static void interpret_nlm_1();
49 static void interpret_nlm_3();
50 static void interpret_nlm_4();
51 static char *nameof_access();
806 char *line;
807 char *pl;
808 ulong_t i;
809
810 if (proc < 0 || proc > MAXPROC_4)
811 return;
812
813 if (flags & F_SUM) {
814 if (setjmp(xdr_err)) {
815 return;
816 }
817
818 line = get_sum_line();
819
820 if (type == CALL) {
821 (void) sprintf(line,
822 "NLM C %s",
823 procnames_short_4[proc]);
824 line += strlen(line);
825 switch (proc) {
826 case NLM4_TEST:
827 case NLM4_GRANTED:
828 case NLM4_TEST_MSG:
829 case NLM4_GRANTED_MSG:
830 /* testargs */
831 (void) strcat(line, sum_netobj("OH"));
832 (void) getxdr_bool(); /* Excl */
833 (void) strcat(line, sum_lock4());
834 break;
835 case NLM4_LOCK:
836 case NLM4_LOCK_MSG:
837 /* lockargs */
838 (void) strcat(line, sum_netobj("OH"));
839 (void) getxdr_bool(); /* Block */
840 (void) getxdr_bool(); /* Excl */
841 (void) strcat(line, sum_lock4());
842 /* ignore reclaim, state fields */
843 break;
844 case NLM4_CANCEL:
845 case NLM4_CANCEL_MSG:
846 /* cancargs */
847 (void) strcat(line, sum_netobj("OH"));
848 (void) getxdr_bool(); /* Block */
849 (void) getxdr_bool(); /* Excl */
850 (void) strcat(line, sum_lock4());
851 break;
852 case NLM4_UNLOCK:
853 case NLM4_UNLOCK_MSG:
854 /* unlockargs */
855 (void) strcat(line, sum_netobj("OH"));
856 (void) strcat(line, sum_lock4());
857 break;
858 case NLM4_TEST_RES:
859 /* testres */
860 (void) strcat(line, sum_netobj("OH"));
861 (void) strcat(line, " ");
862 (void) strcat(line,
863 nameof_stat4(getxdr_u_long()));
864 break;
865 case NLM4_LOCK_RES:
866 case NLM4_CANCEL_RES:
867 case NLM4_UNLOCK_RES:
868 case NLM4_GRANTED_RES:
869 /* res */
870 (void) strcat(line, sum_netobj("OH"));
871 (void) strcat(line, " ");
872 (void) strcat(line,
873 nameof_stat4(getxdr_u_long()));
874 break;
875 case NLM4_SHARE:
876 case NLM4_UNSHARE:
877 (void) strcat(line, sum_netobj("OH"));
878 (void) strcat(line, sum_share());
879 break;
880 case NLM4_NM_LOCK:
881 /* lockargs */
882 skip_netobj(); /* Cookie */
883 (void) getxdr_bool(); /* Block */
884 (void) getxdr_bool(); /* Excl */
885 (void) strcat(line, sum_lock4());
886 /* skip reclaim & state fields */
887 break;
888 case NLM4_FREE_ALL:
889 (void) sprintf(line,
890 " %s", sum_notify());
891 break;
892 }
893 check_retransmit(line, (ulong_t)xid);
894 } else {
895 (void) sprintf(line, "NLM R %s",
896 procnames_short_4[proc]);
897 line += strlen(line);
898 switch (proc) {
899 case NLM4_TEST:
900 /* testres */
901 (void) strcat(line, sum_netobj("OH"));
902 (void) strcat(line, " ");
903 (void) strcat(line,
904 nameof_stat4(getxdr_u_long()));
905 break;
906 case NLM4_LOCK:
907 case NLM4_CANCEL:
908 case NLM4_UNLOCK:
909 case NLM4_GRANTED:
910 case NLM4_NM_LOCK:
911 /* res */
912 (void) strcat(line, sum_netobj("OH"));
913 (void) strcat(line, " ");
914 (void) strcat(line,
915 nameof_stat4(getxdr_u_long()));
916 break;
917 case NLM4_SHARE:
918 case NLM4_UNSHARE:
919 /* shareres */
920 pl = sum_netobj("OH");
921 i = getxdr_u_long();
922 sprintf(line, "%s %s %ld",
923 pl, nameof_stat4(i), getxdr_long());
924 break;
925 case NLM4_FREE_ALL:
926 break;
927 }
928 }
929 }
930
931 if (flags & F_DTAIL) {
932 show_header("NLM: ", "Network Lock Manager", len);
933 show_space();
934 if (setjmp(xdr_err)) {
935 return;
936 }
937 (void) sprintf(get_line(0, 0),
938 "Proc = %d (%s)",
939 proc, procnames_long_4[proc]);
940 if (type == CALL) {
941 switch (proc) {
942 case NLM4_TEST:
943 case NLM4_GRANTED:
944 case NLM4_TEST_MSG:
945 case NLM4_GRANTED_MSG:
946 show_testargs4();
947 break;
948 case NLM4_LOCK:
949 case NLM4_LOCK_MSG:
950 case NLM4_NM_LOCK:
951 show_lockargs4();
952 break;
953 case NLM4_CANCEL:
954 case NLM4_CANCEL_MSG:
955 show_cancargs4();
956 break;
957 case NLM4_UNLOCK:
958 case NLM4_UNLOCK_MSG:
959 show_unlockargs4();
960 break;
961 case NLM4_TEST_RES:
962 show_testres4();
963 break;
964 case NLM4_LOCK_RES:
965 case NLM4_CANCEL_RES:
966 case NLM4_UNLOCK_RES:
967 case NLM4_GRANTED_RES:
968 show_res4();
969 break;
970 case NLM4_SHARE:
971 case NLM4_UNSHARE:
972 show_shareargs();
973 break;
974 case NLM4_FREE_ALL:
975 show_notify();
976 break;
977 }
978 } else {
979 switch (proc) {
980 case NLM4_TEST:
981 show_testres4();
982 break;
983 case NLM4_LOCK:
984 case NLM4_CANCEL:
985 case NLM4_UNLOCK:
986 case NLM4_GRANTED:
987 case NLM_NM_LOCK:
988 show_res4();
989 break;
990 case NLM4_TEST_MSG:
991 case NLM4_LOCK_MSG:
992 case NLM4_CANCEL_MSG:
993 case NLM4_UNLOCK_MSG:
994 case NLM4_GRANTED_MSG:
995 case NLM4_TEST_RES:
996 case NLM4_LOCK_RES:
997 case NLM4_CANCEL_RES:
998 case NLM4_UNLOCK_RES:
999 case NLM4_GRANTED_RES:
1000 break;
1001 case NLM_SHARE:
1002 case NLM_UNSHARE:
1003 show_shareres4();
1004 break;
1005 case NLM_FREE_ALL:
1006 break;
1007 }
1008 }
1009 show_trailer();
1010 }
1011 }
1012
1013 static char *
1014 sum_lock4()
1015 {
1016 static char buff[LM_MAXSTRLEN + 1];
1017 char *cp = buff;
1018 long id;
1019 u_longlong_t off, len;
1070 static void
1071 show_testargs4()
1072 {
1073 show_netobj("Cookie = %s");
1074 showxdr_bool("Exclusive = %s");
1075 show_lock4();
1076 }
1077
1078 static void
1079 show_res4()
1080 {
1081 show_netobj("Cookie = %s");
1082 (void) show_stat4();
1083 }
1084
1085 static char *
1086 nameof_stat4(s)
1087 ulong_t s;
1088 {
1089 switch ((enum nlm4_stats) s) {
1090 case nlm4_granted: return ("granted");
1091 case nlm4_denied: return ("denied");
1092 case nlm4_denied_nolocks:return ("denied (no locks)");
1093 case nlm4_blocked: return ("blocked");
1094 case nlm4_denied_grace_period: return ("denied (grace period)");
1095 case nlm4_deadlck: return ("deadlock");
1096 case nlm4_rofs: return ("read-only fs");
1097 case nlm4_stale_fh: return ("stale fh");
1098 case nlm4_fbig: return ("file too big");
1099 case nlm4_failed: return ("failed");
1100 default: return ("?");
1101 }
1102 }
1103
1104 static enum nlm4_stats
1105 show_stat4()
1106 {
1107 enum nlm4_stats s;
1108
1109 s = (enum nlm4_stats) getxdr_u_long();
1110 (void) sprintf(get_line(0, 0),
1111 "Status = %d (%s)",
1112 s, nameof_stat4((ulong_t)s));
1113
1114 return (s);
1115 }
1116
1117 static void
1118 show_testres4()
1119 {
|