]>
The Tcpdump Group git mirrors - tcpdump/blob - print-rx.c
2 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
3 * uses to communicate between clients and servers.
5 * In this code, I mainly concern myself with decoding the AFS calls, not
6 * with the guts of RX, per se.
8 * Bah. If I never look at rx_packet.h again, it will be too soon.
10 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
16 "@(#) $Id: print-rx.c,v 1.1 1999-11-17 05:45:58 assar Exp $";
19 #include <sys/param.h>
21 #include <sys/types.h>
22 #include <sys/socket.h>
24 #include <netinet/in.h>
25 #include <netinet/in_systm.h>
26 #include <netinet/ip.h>
28 #include "interface.h"
29 #include "addrtoname.h"
31 #undef NOERROR /* Solaris sucks */
32 #include <arpa/nameser.h>
36 static struct tok rx_types
[] = {
37 { RX_PACKET_TYPE_DATA
, "data" },
38 { RX_PACKET_TYPE_ACK
, "ack" },
39 { RX_PACKET_TYPE_BUSY
, "busy" },
40 { RX_PACKET_TYPE_ABORT
, "abort" },
41 { RX_PACKET_TYPE_ACKALL
, "ackall" },
42 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
43 { RX_PACKET_TYPE_RESPONSE
, "response" },
44 { RX_PACKET_TYPE_DEBUG
, "debug" },
45 { RX_PACKET_TYPE_PARAMS
, "params" },
46 { RX_PACKET_TYPE_VERSION
, "version" },
50 static struct tok rx_flags
[] = {
51 { RX_CLIENT_INITIATED
, "client-init" },
52 { RX_REQUEST_ACK
, "req-ack" },
53 { RX_LAST_PACKET
, "last-pckt" },
54 { RX_MORE_PACKETS
, "more-pckts" },
55 { RX_FREE_PACKET
, "free-pckt" }
58 static struct tok fs_req
[] = {
59 { 130, "fetch-data" },
61 { 132, "fetch-status" },
62 { 133, "store-data" },
64 { 135, "store-status" },
65 { 136, "remove-file" },
66 { 137, "create-file" },
72 { 143, "oldsetlock" },
73 { 144, "oldextlock" },
74 { 145, "oldrellock" },
77 { 148, "get-vlinfo" },
78 { 149, "get-vlstats" },
79 { 150, "set-vlstats" },
80 { 151, "get-rootvl" },
81 { 152, "check-token" },
83 { 154, "nget-vlinfo" },
90 { 161, "dfs-lookup" },
91 { 162, "dfs-flushcps" },
92 { 163, "dfs-symlink" },
96 static struct tok cb_req
[] = {
105 { 212, "whoareyou" },
107 { 214, "probeuuid" },
111 static struct tok pt_req
[] = {
113 { 501, "where-is-it" },
114 { 502, "dump-entry" },
115 { 503, "add-to-group" },
116 { 504, "name-to-id" },
117 { 505, "id-to-name" },
119 { 507, "remove-from-group" },
121 { 509, "new-entry" },
124 { 512, "list-entry" },
125 { 513, "change-entry" },
126 { 514, "list-elements" },
127 { 515, "same-mbr-of" },
128 { 516, "set-fld-sentry" },
129 { 517, "list-owned" },
131 { 519, "get-host-cps" },
132 { 520, "update-entry" },
136 static struct tok vldb_req
[] = {
137 { 501, "create-entry" },
138 { 502, "delete-entry" },
139 { 503, "get-entry-by-id" },
140 { 504, "get-entry-by-name" },
141 { 505, "get-new-volume-id" },
142 { 506, "replace-entry" },
143 { 507, "update-entry" },
145 { 509, "releaselock" },
146 { 510, "list-entry" },
147 { 511, "list-attrib" },
148 { 512, "linked-list" },
149 { 513, "get-stats" },
151 { 515, "get-addrs" },
152 { 516, "change-addr" },
153 { 517, "create-entry-n" },
154 { 518, "get-entry-by-id-n" },
155 { 519, "get-entry-by-name-n" },
156 { 520, "replace-entry-n" },
157 { 521, "list-entry-n" },
158 { 522, "list-attrib-n" },
159 { 523, "linked-list-n" },
160 { 524, "update-entry-by-name" },
161 { 525, "create-entry-u" },
162 { 526, "get-entry-by-id-u" },
163 { 527, "get-entry-by-name-u" },
164 { 528, "replace-entry-u" },
165 { 529, "list-entry-u" },
166 { 530, "list-attrib-u" },
167 { 531, "linked-list-u" },
169 { 533, "get-addrs-u" },
173 static struct tok kauth_req
[] = {
175 { 21, "authenticate" },
176 { 22, "authenticate-v2" },
178 { 3, "get-ticket-old" },
179 { 23, "get-ticket" },
182 { 6, "create-user" },
183 { 7, "delete-user" },
189 { 13, "get-random-key" },
191 { 15, "lock-status" },
195 static struct tok vol_req
[] = {
196 { 100, "create-volume" },
197 { 101, "delete-volume" },
200 { 104, "end-trans" },
202 { 106, "set-flags" },
203 { 107, "get-flags" },
204 { 108, "trans-create" },
206 { 110, "get-nth-volume" },
207 { 111, "set-forwarding" },
209 { 113, "get-status" },
210 { 114, "sig-restore" },
211 { 115, "list-partitions" },
212 { 116, "list-volumes" },
213 { 117, "set-id-types" },
215 { 119, "partition-info" },
217 { 121, "list-one-volume" },
220 { 124, "x-list-volumes" },
221 { 125, "x-list-one-volume" },
223 { 127, "x-list-partitions" },
224 { 128, "forward-multiple" },
228 static struct tok bos_req
[] = {
229 { 80, "create-bnode" },
230 { 81, "delete-bnode" },
231 { 82, "set-status" },
232 { 83, "get-status" },
233 { 84, "enumerate-instance" },
234 { 85, "get-instance-info" },
235 { 86, "get-instance-parm" },
236 { 87, "add-superuser" },
237 { 88, "delete-superuser" },
238 { 89, "list-superusers" },
241 { 92, "delete-key" },
242 { 93, "set-cell-name" },
243 { 94, "get-cell-name" },
244 { 95, "get-cell-host" },
245 { 96, "add-cell-host" },
246 { 97, "delete-cell-host" },
247 { 98, "set-t-status" },
248 { 99, "shutdown-all" },
249 { 100, "restart-all" },
250 { 101, "startup-all" },
251 { 102, "set-noauth-flag" },
254 { 105, "start-bozo-install" },
255 { 106, "uninstall" },
256 { 107, "get-dates" },
259 { 110, "set-restart-time" },
260 { 111, "get-restart-time" },
261 { 112, "start-bozo-log" },
263 { 114, "get-instance-strings" },
267 static struct tok ubik_req
[] = {
268 { 10000, "vote-beacon" },
269 { 10001, "vote-debug-old" },
270 { 10002, "vote-sdebug-old" },
271 { 10003, "vote-getsyncsite" },
272 { 10004, "vote-debug" },
273 { 10005, "vote-sdebug" },
274 { 20000, "disk-begin" },
275 { 20001, "disk-commit" },
276 { 20002, "disk-lock" },
277 { 20003, "disk-write" },
278 { 20004, "disk-getversion" },
279 { 20005, "disk-getfile" },
280 { 20006, "disk-sendfile" },
281 { 20007, "disk-abort" },
282 { 20008, "disk-releaselocks" },
283 { 20009, "disk-truncate" },
284 { 20010, "disk-probe" },
285 { 20011, "disk-writev" },
286 { 20012, "disk-interfaceaddr" },
287 { 20013, "disk-setversion" },
291 #define VOTE_LOW 10000
292 #define VOTE_HIGH 10005
293 #define DISK_LOW 20000
294 #define DISK_HIGH 20013
296 static struct tok cb_types
[] = {
303 static struct tok ubik_lock_types
[] = {
310 static char *voltype
[] = { "read-write", "read-only", "backup" };
313 * Cache entries we keep around so we can figure out the RX opcode
314 * numbers for replies. This allows us to make sense of RX reply packets.
317 struct rx_cache_entry
{
318 u_int32_t callnum
; /* Call number (net order) */
319 struct in_addr client
; /* client IP address (net order) */
320 struct in_addr server
; /* server IP address (net order) */
321 int dport
; /* server port (host order) */
322 u_short serviceId
; /* Service identifier (net order) */
323 u_int32_t opcode
; /* RX opcode (host order) */
326 #define RX_CACHE_SIZE 64
328 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
330 static int rx_cache_next
= 0;
331 static int rx_cache_hint
= 0;
332 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
333 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
336 static void fs_print(const u_char
*, int);
337 static void fs_reply_print(const u_char
*, int, int32_t);
338 static void acl_print(u_char
*, u_char
*);
339 static void cb_print(const u_char
*, int);
340 static void cb_reply_print(const u_char
*, int, int32_t);
341 static void prot_print(const u_char
*, int);
342 static void prot_reply_print(const u_char
*, int, int32_t);
343 static void vldb_print(const u_char
*, int);
344 static void vldb_reply_print(const u_char
*, int, int32_t);
345 static void kauth_print(const u_char
*, int);
346 static void kauth_reply_print(const u_char
*, int, int32_t);
347 static void vol_print(const u_char
*, int);
348 static void vol_reply_print(const u_char
*, int, int32_t);
349 static void bos_print(const u_char
*, int);
350 static void bos_reply_print(const u_char
*, int, int32_t);
351 static void ubik_print(const u_char
*, int);
352 static void ubik_reply_print(const u_char
*, int, int32_t);
354 static int is_ubik(u_int32_t
);
357 * Handle the rx-level packet. See if we know what port it's going to so
358 * we can peek at the afs call inside
362 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
365 register struct rx_header
*rxh
;
369 if (snapend
- bp
< sizeof (struct rx_header
)) {
370 printf(" [|rx] (%d)", length
);
374 rxh
= (struct rx_header
*) bp
;
376 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
380 printf(" cid %08x call# %d seq %d ser %d",
381 (int) ntohl(rxh
->cid
),
382 (int) ntohl(rxh
->callNumber
),
383 (int) ntohl(rxh
->seq
),
384 (int) ntohl(rxh
->serial
));
386 printf(" secindex %d serviceid %hu",
387 (int) rxh
->securityIndex
,
388 ntohs(rxh
->serviceId
));
389 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
390 if (rxh
->flags
& rx_flags
[i
].v
) {
397 printf("<%s>", rx_flags
[i
].s
);
403 * Try to handle AFS calls that we know about. Check the destination
404 * port and make sure it's a data packet. Also, make sure the
405 * seq number is 1 (because otherwise it's a continuation packet,
406 * and we can't interpret that). Also, seems that reply packets
407 * do not have the client-init flag set, so we check for that
411 if (rxh
->type
== RX_PACKET_TYPE_DATA
&& ntohl(rxh
->seq
) == 1 &&
412 rxh
->flags
& RX_CLIENT_INITIATED
) {
415 * Insert this call into the call cache table, so we
416 * have a chance to print out replies
419 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
422 case FS_RX_PORT
: /* AFS file service */
423 fs_print(bp
, length
);
425 case CB_RX_PORT
: /* AFS callback service */
426 cb_print(bp
, length
);
428 case PROT_RX_PORT
: /* AFS protection service */
429 prot_print(bp
, length
);
431 case VLDB_RX_PORT
: /* AFS VLDB service */
432 vldb_print(bp
, length
);
434 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
435 kauth_print(bp
, length
);
437 case VOL_RX_PORT
: /* AFS Volume service */
438 vol_print(bp
, length
);
440 case BOS_RX_PORT
: /* AFS BOS service */
441 bos_print(bp
, length
);
448 * If it's a reply (client-init is _not_ set, but seq is one)
449 * then look it up in the cache. If we find it, call the reply
450 * printing functions Note that we handle abort packets here,
451 * because printing out the return code can be useful at times.
454 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
455 ntohl(rxh
->seq
) == 1) ||
456 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
457 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
458 rx_cache_find(rxh
, (const struct ip
*) bp2
,
462 case FS_RX_PORT
: /* AFS file service */
463 fs_reply_print(bp
, length
, opcode
);
465 case CB_RX_PORT
: /* AFS callback service */
466 cb_reply_print(bp
, length
, opcode
);
468 case PROT_RX_PORT
: /* AFS PT service */
469 prot_reply_print(bp
, length
, opcode
);
471 case VLDB_RX_PORT
: /* AFS VLDB service */
472 vldb_reply_print(bp
, length
, opcode
);
474 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
475 kauth_reply_print(bp
, length
, opcode
);
477 case VOL_RX_PORT
: /* AFS Volume service */
478 vol_reply_print(bp
, length
, opcode
);
480 case BOS_RX_PORT
: /* AFS BOS service */
481 bos_reply_print(bp
, length
, opcode
);
489 printf(" (%d)", length
);
493 * Insert an entry into the cache. Taken from print-nfs.c
497 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
500 struct rx_cache_entry
*rxent
;
501 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
503 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
506 rxent
= &rx_cache
[rx_cache_next
];
508 if (++rx_cache_next
>= RX_CACHE_SIZE
)
511 rxent
->callnum
= rxh
->callNumber
;
512 rxent
->client
= ip
->ip_src
;
513 rxent
->server
= ip
->ip_dst
;
514 rxent
->dport
= dport
;
515 rxent
->serviceId
= rxh
->serviceId
;
516 rxent
->opcode
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
520 * Lookup an entry in the cache. Also taken from print-nfs.c
522 * Note that because this is a reply, we're looking at the _source_
527 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
531 struct rx_cache_entry
*rxent
;
532 u_int32_t clip
= ip
->ip_dst
.s_addr
;
533 u_int32_t sip
= ip
->ip_src
.s_addr
;
535 /* Start the search where we last left off */
539 rxent
= &rx_cache
[i
];
540 if (rxent
->callnum
== rxh
->callNumber
&&
541 rxent
->client
.s_addr
== clip
&&
542 rxent
->server
.s_addr
== sip
&&
543 rxent
->serviceId
== rxh
->serviceId
&&
544 rxent
->dport
== sport
) {
546 /* We got a match! */
549 *opcode
= rxent
->opcode
;
552 if (++i
> RX_CACHE_SIZE
)
554 } while (i
!= rx_cache_hint
);
556 /* Our search failed */
561 * These extrememly grody macros handle the printing of various AFS stuff.
564 #define TRUNC(n) if (snapend - bp + 1 <= n) goto trunc;
565 #define FIDOUT() { unsigned long n1, n2, n3; \
566 TRUNC(sizeof(int32_t) * 3); \
567 n1 = ntohl(*((int *) bp)); \
568 bp += sizeof(int32_t); \
569 n2 = ntohl(*((int *) bp)); \
570 bp += sizeof(int32_t); \
571 n3 = ntohl(*((int *) bp)); \
572 bp += sizeof(int32_t); \
573 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
576 #define STROUT(MAX) { int i; \
577 TRUNC(sizeof(int32_t)); \
578 i = (int) ntohl(*((int *) bp)); \
579 bp += sizeof(int32_t); \
581 strncpy(s, bp, min(MAX, i)); \
583 printf(" \"%s\"", s); \
584 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
587 #define INTOUT() { int i; \
588 TRUNC(sizeof(int32_t)); \
589 i = (int) ntohl(*((int *) bp)); \
590 bp += sizeof(int32_t); \
594 #define UINTOUT() { unsigned long i; \
595 TRUNC(sizeof(int32_t)); \
596 i = ntohl(*((int *) bp)); \
597 bp += sizeof(int32_t); \
601 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
602 TRUNC(sizeof(int32_t)); \
603 t = (time_t) ntohl(*((int *) bp)); \
604 bp += sizeof(int32_t); \
605 tm = localtime(&t); \
606 strftime(str, 256, "%D %T", tm); \
607 printf(" %s", str); \
610 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
611 TRUNC(sizeof(int32_t) * 2); \
612 epoch = ntohl(*((int *) bp)); \
613 bp += sizeof(int32_t); \
614 counter = ntohl(*((int *) bp)); \
615 bp += sizeof(int32_t); \
616 printf(" %d.%d", epoch, counter); \
619 #define AFSUUIDOUT() {u_int32_t temp; int i; \
620 TRUNC(11*sizeof(u_int32_t)); \
621 temp = ntohl(*((int *) bp)); \
622 bp += sizeof(u_int32_t); \
623 printf(" %08x", temp); \
624 temp = ntohl(*((int *) bp)); \
625 bp += sizeof(u_int32_t); \
626 printf("%04x", temp); \
627 temp = ntohl(*((int *) bp)); \
628 bp += sizeof(u_int32_t); \
629 printf("%04x", temp); \
630 for (i = 0; i < 8; i++) { \
631 temp = ntohl(*((int *) bp)); \
632 bp += sizeof(u_int32_t); \
633 printf("%02x", (unsigned char) temp); \
638 * This is the sickest one of all
641 #define VECOUT(MAX) { char *sp; \
643 TRUNC(MAX * sizeof(int32_t)); \
645 for (k = 0; k < MAX; k++) { \
646 *sp++ = (char) ntohl(*((int *) bp)); \
647 bp += sizeof(int32_t); \
650 printf(" \"%s\"", s); \
654 * Handle calls to the AFS file service (fs)
658 fs_print(register const u_char
*bp
, int length
)
664 if (length
<= sizeof(struct rx_header
))
667 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
672 * Print out the afs call we're invoking. The table used here was
673 * gleaned from fsint/afsint.xg
676 fs_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
678 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
681 * Print out arguments to some of the AFS calls. This stuff is
685 bp
+= sizeof(struct rx_header
) + 4;
688 * Sigh. This is gross. Ritchie forgive me.
692 case 130: /* Fetch data */
699 case 131: /* Fetch ACL */
700 case 132: /* Fetch Status */
701 case 135: /* Store status */
702 case 143: /* Old set lock */
703 case 144: /* Old extend lock */
704 case 145: /* Old release lock */
705 case 156: /* Set lock */
706 case 157: /* Extend lock */
707 case 158: /* Release lock */
710 case 133: /* Store data */
712 TRUNC(sizeof(int32_t)*6); /* Skip past this */
713 bp
+= sizeof(int32_t) * 6;
721 case 134: /* Store ACL */
726 i
= ntohl(*((int *) bp
));
727 bp
+= sizeof(int32_t);
729 strncpy(a
, bp
, min(AFSOPAQUEMAX
, i
));
731 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
734 case 136: /* Remove file */
735 case 137: /* Create file */
736 case 141: /* MakeDir */
737 case 142: /* Remove directory */
741 case 138: /* Rename file */
749 case 139: /* Symlink */
761 case 148: /* Get volume info */
764 case 149: /* Get volume stats */
765 case 150: /* Set volume stats */
769 case 154: /* New get volume info */
773 case 155: /* Bulk stat */
777 j
= ntohl(*((int *) bp
));
778 bp
+= sizeof(int32_t);
780 for (i
= 0; i
< j
; i
++) {
799 * Handle replies to the AFS file service
803 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
807 struct rx_header
*rxh
;
809 if (length
<= sizeof(struct rx_header
))
812 rxh
= (struct rx_header
*) bp
;
815 * Print out the afs call we're invoking. The table used here was
816 * gleaned from fsint/afsint.xg
819 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
821 bp
+= sizeof(struct rx_header
);
824 * If it was a data packet, interpret the response
827 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
829 case 131: /* Fetch ACL */
833 i
= ntohl(*((int *) bp
));
834 bp
+= sizeof(int32_t);
836 strncpy(a
, bp
, min(AFSOPAQUEMAX
, i
));
838 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
841 case 137: /* Create file */
842 case 141: /* MakeDir */
846 case 151: /* Get root volume */
847 printf(" root volume");
850 case 153: /* Get time */
858 * Otherwise, just print out the return code
871 * Print out an AFS ACL string. An AFS ACL is a string that has the
874 * <positive> <negative>
878 * "positive" and "negative" are integers which contain the number of
879 * positive and negative ACL's in the string. The uid/aclbits pair are
880 * ASCII strings containing the UID/PTS record and and a ascii number
881 * representing a logical OR of all the ACL permission bits
885 acl_print(u_char
*s
, u_char
*end
)
891 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
900 * This wacky order preserves the order used by the "fs" command
903 #define ACLOUT(acl) \
904 if (acl & PRSFS_READ) \
906 if (acl & PRSFS_LOOKUP) \
908 if (acl & PRSFS_INSERT) \
910 if (acl & PRSFS_DELETE) \
912 if (acl & PRSFS_WRITE) \
914 if (acl & PRSFS_LOCK) \
916 if (acl & PRSFS_ADMINISTER) \
919 for (i
= 0; i
< pos
; i
++) {
920 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
923 printf(" +{%s ", user
);
930 for (i
= 0; i
< neg
; i
++) {
931 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
934 printf(" -{%s ", user
);
945 * Handle calls to the AFS callback service
949 cb_print(register const u_char
*bp
, int length
)
954 if (length
<= sizeof(struct rx_header
))
957 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
962 * Print out the afs call we're invoking. The table used here was
963 * gleaned from fsint/afscbint.xg
966 cb_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
968 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
970 bp
+= sizeof(struct rx_header
) + 4;
973 * Print out the afs call we're invoking. The table used here was
974 * gleaned from fsint/afscbint.xg
978 case 204: /* Callback */
982 j
= ntohl(*((int *) bp
));
983 bp
+= sizeof(int32_t);
985 for (i
= 0; i
< j
; i
++) {
994 j
= ntohl(*((int *) bp
));
995 bp
+= sizeof(int32_t);
1000 for (i
= 0; i
< j
; i
++) {
1006 t
= ntohl(*((int *) bp
));
1007 bp
+= sizeof(int32_t);
1008 tok2str(cb_types
, "type %d", t
);
1022 * Handle replies to the AFS Callback Service
1026 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1030 struct rx_header
*rxh
;
1032 if (length
<= sizeof(struct rx_header
))
1035 rxh
= (struct rx_header
*) bp
;
1038 * Print out the afs call we're invoking. The table used here was
1039 * gleaned from fsint/afscbint.xg
1042 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1044 bp
+= sizeof(struct rx_header
);
1047 * If it was a data packet, interpret the response.
1050 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1051 /* Well, no, not really. Leave this for later */
1055 * Otherwise, just print out the return code
1068 * Handle calls to the AFS protection database server
1072 prot_print(register const u_char
*bp
, int length
)
1078 if (length
<= sizeof(struct rx_header
))
1081 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1086 * Print out the afs call we're invoking. The table used here was
1087 * gleaned from ptserver/ptint.xg
1090 pt_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1094 if (is_ubik(pt_op
)) {
1095 ubik_print(bp
, length
);
1099 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1102 * Decode some of the arguments to the PT calls
1105 bp
+= sizeof(struct rx_header
) + 4;
1108 case 500: /* I New User */
1115 case 501: /* Where is it */
1116 case 506: /* Delete */
1117 case 508: /* Get CPS */
1118 case 512: /* List entry */
1119 case 514: /* List elements */
1120 case 517: /* List owned */
1121 case 518: /* Get CPS2 */
1122 case 519: /* Get host CPS */
1126 case 502: /* Dump entry */
1130 case 503: /* Add to group */
1131 case 507: /* Remove from group */
1132 case 515: /* Is a member of? */
1138 case 504: /* Name to ID */
1142 j
= ntohl(*((int *) bp
));
1143 bp
+= sizeof(int32_t);
1146 * Who designed this chicken-shit protocol?
1148 * Each character is stored as a 32-bit
1152 for (i
= 0; i
< j
; i
++) {
1159 case 505: /* Id to name */
1164 i
= ntohl(*((int *) bp
));
1165 bp
+= sizeof(int32_t);
1166 for (j
= 0; j
< i
; j
++)
1172 case 509: /* New entry */
1179 case 511: /* Set max */
1185 case 513: /* Change entry */
1194 case 520: /* Update entry */
1211 * Handle replies to the AFS protection service
1215 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1217 struct rx_header
*rxh
;
1221 if (length
< sizeof(struct rx_header
))
1224 rxh
= (struct rx_header
*) bp
;
1227 * Print out the afs call we're invoking. The table used here was
1228 * gleaned from ptserver/ptint.xg. Check to see if it's a
1229 * Ubik call, however.
1234 if (is_ubik(opcode
)) {
1235 ubik_reply_print(bp
, length
, opcode
);
1239 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1241 bp
+= sizeof(struct rx_header
);
1244 * If it was a data packet, interpret the response
1247 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1249 case 504: /* Name to ID */
1254 i
= ntohl(*((int *) bp
));
1255 bp
+= sizeof(int32_t);
1256 for (j
= 0; j
< i
; j
++)
1262 case 505: /* ID to name */
1266 j
= ntohl(*((int *) bp
));
1267 bp
+= sizeof(int32_t);
1270 * Who designed this chicken-shit protocol?
1272 * Each character is stored as a 32-bit
1276 for (i
= 0; i
< j
; i
++) {
1283 case 508: /* Get CPS */
1284 case 514: /* List elements */
1285 case 517: /* List owned */
1286 case 518: /* Get CPS2 */
1287 case 519: /* Get host CPS */
1291 j
= ntohl(*((int *) bp
));
1292 bp
+= sizeof(int32_t);
1293 for (i
= 0; i
< j
; i
++) {
1300 case 510: /* List max */
1311 * Otherwise, just print out the return code
1324 * Handle calls to the AFS volume location database service
1328 vldb_print(register const u_char
*bp
, int length
)
1334 if (length
<= sizeof(struct rx_header
))
1337 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1342 * Print out the afs call we're invoking. The table used here was
1343 * gleaned from vlserver/vldbint.xg
1346 vldb_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1350 if (is_ubik(vldb_op
)) {
1351 ubik_print(bp
, length
);
1354 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1357 * Decode some of the arguments to the VLDB calls
1360 bp
+= sizeof(struct rx_header
) + 4;
1363 case 501: /* Create new volume */
1364 case 517: /* Create entry N */
1367 case 502: /* Delete entry */
1368 case 503: /* Get entry by ID */
1369 case 507: /* Update entry */
1370 case 508: /* Set lock */
1371 case 509: /* Release lock */
1372 case 518: /* Get entry by ID N */
1375 TRUNC(sizeof(int32_t));
1376 i
= ntohl(*((int *) bp
));
1377 bp
+= sizeof(int32_t);
1379 printf(" type %s", voltype
[i
]);
1381 case 504: /* Get entry by name */
1382 case 519: /* Get entry by name N */
1383 case 524: /* Update entry by name */
1384 case 527: /* Get entry by name U */
1387 case 505: /* Get new vol id */
1391 case 506: /* Replace entry */
1392 case 520: /* Replace entry N */
1395 TRUNC(sizeof(int32_t));
1396 i
= ntohl(*((int *) bp
));
1397 bp
+= sizeof(int32_t);
1399 printf(" type %s", voltype
[i
]);
1402 case 510: /* List entry */
1403 case 521: /* List entry N */
1418 * Handle replies to the AFS volume location database service
1422 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1424 struct rx_header
*rxh
;
1428 if (length
< sizeof(struct rx_header
))
1431 rxh
= (struct rx_header
*) bp
;
1434 * Print out the afs call we're invoking. The table used here was
1435 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1436 * Ubik call, however.
1441 if (is_ubik(opcode
)) {
1442 ubik_reply_print(bp
, length
, opcode
);
1446 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1448 bp
+= sizeof(struct rx_header
);
1451 * If it was a data packet, interpret the response
1454 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1456 case 510: /* List entry */
1459 printf(" nextindex");
1461 case 503: /* Get entry by id */
1462 case 504: /* Get entry by name */
1463 { unsigned long nservers
, j
;
1465 TRUNC(sizeof(int32_t));
1466 bp
+= sizeof(int32_t);
1467 printf(" numservers");
1468 TRUNC(sizeof(int32_t));
1469 nservers
= ntohl(*((int *) bp
));
1470 bp
+= sizeof(int32_t);
1471 printf(" %d", nservers
);
1473 for (i
= 0; i
< 8; i
++) {
1474 TRUNC(sizeof(int32_t));
1477 inet_ntoa(*((struct in_addr
*) bp
)));
1478 bp
+= sizeof(int32_t);
1480 printf(" partitions");
1481 for (i
= 0; i
< 8; i
++) {
1482 TRUNC(sizeof(int32_t));
1483 j
= ntohl(*((int *) bp
));
1484 if (i
< nservers
&& j
<= 26)
1485 printf(" %c", 'a' + j
);
1486 else if (i
< nservers
)
1488 bp
+= sizeof(int32_t);
1490 TRUNC(8 * sizeof(int32_t));
1491 bp
+= 8 * sizeof(int32_t);
1500 case 505: /* Get new volume ID */
1504 case 521: /* List entry */
1505 case 529: /* List entry U */
1508 printf(" nextindex");
1510 case 518: /* Get entry by ID N */
1511 case 519: /* Get entry by name N */
1512 { unsigned long nservers
, j
;
1514 printf(" numservers");
1515 TRUNC(sizeof(int32_t));
1516 nservers
= ntohl(*((int *) bp
));
1517 bp
+= sizeof(int32_t);
1518 printf(" %d", nservers
);
1520 for (i
= 0; i
< 13; i
++) {
1521 TRUNC(sizeof(int32_t));
1524 inet_ntoa(*((struct in_addr
*) bp
)));
1525 bp
+= sizeof(int32_t);
1527 printf(" partitions");
1528 for (i
= 0; i
< 13; i
++) {
1529 TRUNC(sizeof(int32_t));
1530 j
= ntohl(*((int *) bp
));
1531 if (i
< nservers
&& j
<= 26)
1532 printf(" %c", 'a' + j
);
1533 else if (i
< nservers
)
1535 bp
+= sizeof(int32_t);
1537 TRUNC(13 * sizeof(int32_t));
1538 bp
+= 13 * sizeof(int32_t);
1547 case 526: /* Get entry by ID U */
1548 case 527: /* Get entry by name U */
1549 { unsigned long nservers
, j
;
1551 printf(" numservers");
1552 TRUNC(sizeof(int32_t));
1553 nservers
= ntohl(*((int *) bp
));
1554 bp
+= sizeof(int32_t);
1555 printf(" %d", nservers
);
1557 for (i
= 0; i
< 13; i
++) {
1568 printf(" partitions");
1569 for (i
= 0; i
< 13; i
++) {
1570 TRUNC(sizeof(int32_t));
1571 j
= ntohl(*((int *) bp
));
1572 if (i
< nservers
&& j
<= 26)
1573 printf(" %c", 'a' + j
);
1574 else if (i
< nservers
)
1576 bp
+= sizeof(int32_t);
1578 TRUNC(13 * sizeof(int32_t));
1579 bp
+= 13 * sizeof(int32_t);
1593 * Otherwise, just print out the return code
1606 * Handle calls to the AFS Kerberos Authentication service
1610 kauth_print(register const u_char
*bp
, int length
)
1615 if (length
<= sizeof(struct rx_header
))
1618 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1623 * Print out the afs call we're invoking. The table used here was
1624 * gleaned from kauth/kauth.rg
1627 kauth_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1631 if (is_ubik(kauth_op
)) {
1632 ubik_print(bp
, length
);
1637 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1640 * Decode some of the arguments to the KA calls
1643 bp
+= sizeof(struct rx_header
) + 4;
1646 case 1: /* Authenticate old */;
1647 case 21: /* Authenticate */
1648 case 22: /* Authenticate-V2 */
1649 case 2: /* Change PW */
1650 case 5: /* Set fields */
1651 case 6: /* Create user */
1652 case 7: /* Delete user */
1653 case 8: /* Get entry */
1654 case 14: /* Unlock */
1655 case 15: /* Lock status */
1656 printf(" principal");
1660 case 3: /* GetTicket-old */
1661 case 23: /* GetTicket */
1668 TRUNC(sizeof(int32_t));
1669 i
= (int) ntohl(*((int *) bp
));
1670 bp
+= sizeof(int32_t);
1673 printf(" principal");
1678 case 4: /* Set Password */
1679 printf(" principal");
1685 case 12: /* Get password */
1696 printf(" [|kauth]");
1700 * Handle replies to the AFS Kerberos Authentication Service
1704 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1708 struct rx_header
*rxh
;
1710 if (length
<= sizeof(struct rx_header
))
1713 rxh
= (struct rx_header
*) bp
;
1716 * Print out the afs call we're invoking. The table used here was
1717 * gleaned from kauth/kauth.rg
1722 if (is_ubik(opcode
)) {
1723 ubik_reply_print(bp
, length
, opcode
);
1727 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1729 bp
+= sizeof(struct rx_header
);
1732 * If it was a data packet, interpret the response.
1735 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1736 /* Well, no, not really. Leave this for later */
1740 * Otherwise, just print out the return code
1749 printf(" [|kauth]");
1753 * Handle calls to the AFS Volume location service
1757 vol_print(register const u_char
*bp
, int length
)
1761 if (length
<= sizeof(struct rx_header
))
1764 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1769 * Print out the afs call we're invoking. The table used here was
1770 * gleaned from volser/volint.xg
1773 vol_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1775 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1778 * Normally there would be a switch statement here to decode the
1779 * arguments to the AFS call, but since I don't have access to
1780 * an AFS server (yet) and I'm not an AFS admin, I can't
1781 * test any of these calls. Leave this blank for now.
1791 * Handle replies to the AFS Volume Service
1795 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1799 struct rx_header
*rxh
;
1801 if (length
<= sizeof(struct rx_header
))
1804 rxh
= (struct rx_header
*) bp
;
1807 * Print out the afs call we're invoking. The table used here was
1808 * gleaned from volser/volint.xg
1811 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
1813 bp
+= sizeof(struct rx_header
);
1816 * If it was a data packet, interpret the response.
1819 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1820 /* Well, no, not really. Leave this for later */
1824 * Otherwise, just print out the return code
1837 * Handle calls to the AFS BOS service
1841 bos_print(register const u_char
*bp
, int length
)
1846 if (length
<= sizeof(struct rx_header
))
1849 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1854 * Print out the afs call we're invoking. The table used here was
1855 * gleaned from bozo/bosint.xg
1858 bos_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1860 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
1863 * Decode some of the arguments to the BOS calls
1866 bp
+= sizeof(struct rx_header
) + 4;
1869 case 80: /* Create B node */
1872 printf(" instance");
1875 case 81: /* Delete B node */
1876 case 83: /* Get status */
1877 case 85: /* Get instance info */
1878 case 87: /* Add super user */
1879 case 88: /* Delete super user */
1880 case 93: /* Set cell name */
1881 case 96: /* Add cell host */
1882 case 97: /* Delete cell host */
1883 case 104: /* Restart */
1884 case 106: /* Uninstall */
1885 case 108: /* Exec */
1886 case 112: /* Getlog */
1887 case 114: /* Get instance strings */
1890 case 82: /* Set status */
1891 case 98: /* Set T status */
1896 case 86: /* Get instance parm */
1901 case 84: /* Enumerate instance */
1902 case 89: /* List super users */
1903 case 90: /* List keys */
1904 case 91: /* Add key */
1905 case 92: /* Delete key */
1906 case 95: /* Get cell host */
1909 case 105: /* Install */
1929 * Handle replies to the AFS BOS Service
1933 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1937 struct rx_header
*rxh
;
1939 if (length
<= sizeof(struct rx_header
))
1942 rxh
= (struct rx_header
*) bp
;
1945 * Print out the afs call we're invoking. The table used here was
1946 * gleaned from volser/volint.xg
1949 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
1951 bp
+= sizeof(struct rx_header
);
1954 * If it was a data packet, interpret the response.
1957 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1958 /* Well, no, not really. Leave this for later */
1962 * Otherwise, just print out the return code
1975 * Check to see if this is a Ubik opcode.
1979 is_ubik(u_int32_t opcode
)
1981 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
1982 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
1989 * Handle Ubik opcodes to any one of the replicated database services
1993 ubik_print(register const u_char
*bp
, int length
)
1999 * Print out the afs call we're invoking. The table used here was
2000 * gleaned from ubik/ubik_int.xg
2003 ubik_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
2005 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2008 * Decode some of the arguments to the Ubik calls
2011 bp
+= sizeof(struct rx_header
) + 4;
2014 case 10000: /* Beacon */
2016 temp
= ntohl(*((int *) bp
));
2017 bp
+= sizeof(int32_t);
2018 printf(" syncsite %s", temp
? "yes" : "no");
2019 printf(" votestart");
2021 printf(" dbversion");
2026 case 10003: /* Get sync site */
2030 case 20000: /* Begin */
2031 case 20001: /* Commit */
2032 case 20007: /* Abort */
2033 case 20008: /* Release locks */
2034 case 20010: /* Writev */
2038 case 20002: /* Lock */
2047 temp
= ntohl(*((int *) bp
));
2048 bp
+= sizeof(int32_t);
2049 tok2str(ubik_lock_types
, "type %d", temp
);
2051 case 20003: /* Write */
2059 case 20005: /* Get file */
2063 case 20006: /* Send file */
2068 printf(" dbversion");
2071 case 20009: /* Truncate */
2079 case 20012: /* Set version */
2082 printf(" oldversion");
2084 printf(" newversion");
2098 * Handle Ubik replies to any one of the replicated database services
2102 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2104 struct rx_header
*rxh
;
2106 if (length
< sizeof(struct rx_header
))
2109 rxh
= (struct rx_header
*) bp
;
2112 * Print out the ubik call we're invoking. This table was gleaned
2113 * from ubik/ubik_int.xg
2116 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2118 bp
+= sizeof(struct rx_header
);
2121 * If it was a data packet, print out the arguments to the Ubik calls
2124 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2126 case 10000: /* Beacon */
2129 case 20004: /* Get version */
2130 printf(" dbversion");
2138 * Otherwise, print out "yes" it it was a beacon packet (because
2139 * that's how yes votes are returned, go figure), otherwise
2140 * just print out the error code.
2145 case 10000: /* Beacon */
2146 printf(" vote yes until");