]>
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>
15 static const char rcsid
[] =
16 "@(#) $Id: print-rx.c,v 1.5 1999-12-15 08:10:18 fenner Exp $";
25 #include <sys/param.h>
27 #include <sys/types.h>
28 #include <sys/socket.h>
29 #include <netinet/in.h>
30 #include <netinet/in_systm.h>
31 #include <netinet/ip.h>
32 #include <arpa/inet.h>
34 #include "interface.h"
35 #include "addrtoname.h"
37 #undef NOERROR /* Solaris sucks */
38 #include <arpa/nameser.h>
42 static struct tok rx_types
[] = {
43 { RX_PACKET_TYPE_DATA
, "data" },
44 { RX_PACKET_TYPE_ACK
, "ack" },
45 { RX_PACKET_TYPE_BUSY
, "busy" },
46 { RX_PACKET_TYPE_ABORT
, "abort" },
47 { RX_PACKET_TYPE_ACKALL
, "ackall" },
48 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
49 { RX_PACKET_TYPE_RESPONSE
, "response" },
50 { RX_PACKET_TYPE_DEBUG
, "debug" },
51 { RX_PACKET_TYPE_PARAMS
, "params" },
52 { RX_PACKET_TYPE_VERSION
, "version" },
56 static struct tok rx_flags
[] = {
57 { RX_CLIENT_INITIATED
, "client-init" },
58 { RX_REQUEST_ACK
, "req-ack" },
59 { RX_LAST_PACKET
, "last-pckt" },
60 { RX_MORE_PACKETS
, "more-pckts" },
61 { RX_FREE_PACKET
, "free-pckt" }
64 static struct tok fs_req
[] = {
65 { 130, "fetch-data" },
67 { 132, "fetch-status" },
68 { 133, "store-data" },
70 { 135, "store-status" },
71 { 136, "remove-file" },
72 { 137, "create-file" },
78 { 143, "oldsetlock" },
79 { 144, "oldextlock" },
80 { 145, "oldrellock" },
83 { 148, "get-vlinfo" },
84 { 149, "get-vlstats" },
85 { 150, "set-vlstats" },
86 { 151, "get-rootvl" },
87 { 152, "check-token" },
89 { 154, "nget-vlinfo" },
96 { 161, "dfs-lookup" },
97 { 162, "dfs-flushcps" },
98 { 163, "dfs-symlink" },
102 static struct tok cb_req
[] = {
111 { 212, "whoareyou" },
113 { 214, "probeuuid" },
117 static struct tok pt_req
[] = {
119 { 501, "where-is-it" },
120 { 502, "dump-entry" },
121 { 503, "add-to-group" },
122 { 504, "name-to-id" },
123 { 505, "id-to-name" },
125 { 507, "remove-from-group" },
127 { 509, "new-entry" },
130 { 512, "list-entry" },
131 { 513, "change-entry" },
132 { 514, "list-elements" },
133 { 515, "same-mbr-of" },
134 { 516, "set-fld-sentry" },
135 { 517, "list-owned" },
137 { 519, "get-host-cps" },
138 { 520, "update-entry" },
142 static struct tok vldb_req
[] = {
143 { 501, "create-entry" },
144 { 502, "delete-entry" },
145 { 503, "get-entry-by-id" },
146 { 504, "get-entry-by-name" },
147 { 505, "get-new-volume-id" },
148 { 506, "replace-entry" },
149 { 507, "update-entry" },
151 { 509, "releaselock" },
152 { 510, "list-entry" },
153 { 511, "list-attrib" },
154 { 512, "linked-list" },
155 { 513, "get-stats" },
157 { 515, "get-addrs" },
158 { 516, "change-addr" },
159 { 517, "create-entry-n" },
160 { 518, "get-entry-by-id-n" },
161 { 519, "get-entry-by-name-n" },
162 { 520, "replace-entry-n" },
163 { 521, "list-entry-n" },
164 { 522, "list-attrib-n" },
165 { 523, "linked-list-n" },
166 { 524, "update-entry-by-name" },
167 { 525, "create-entry-u" },
168 { 526, "get-entry-by-id-u" },
169 { 527, "get-entry-by-name-u" },
170 { 528, "replace-entry-u" },
171 { 529, "list-entry-u" },
172 { 530, "list-attrib-u" },
173 { 531, "linked-list-u" },
175 { 533, "get-addrs-u" },
179 static struct tok kauth_req
[] = {
181 { 21, "authenticate" },
182 { 22, "authenticate-v2" },
184 { 3, "get-ticket-old" },
185 { 23, "get-ticket" },
188 { 6, "create-user" },
189 { 7, "delete-user" },
195 { 13, "get-random-key" },
197 { 15, "lock-status" },
201 static struct tok vol_req
[] = {
202 { 100, "create-volume" },
203 { 101, "delete-volume" },
206 { 104, "end-trans" },
208 { 106, "set-flags" },
209 { 107, "get-flags" },
210 { 108, "trans-create" },
212 { 110, "get-nth-volume" },
213 { 111, "set-forwarding" },
215 { 113, "get-status" },
216 { 114, "sig-restore" },
217 { 115, "list-partitions" },
218 { 116, "list-volumes" },
219 { 117, "set-id-types" },
221 { 119, "partition-info" },
223 { 121, "list-one-volume" },
226 { 124, "x-list-volumes" },
227 { 125, "x-list-one-volume" },
229 { 127, "x-list-partitions" },
230 { 128, "forward-multiple" },
234 static struct tok bos_req
[] = {
235 { 80, "create-bnode" },
236 { 81, "delete-bnode" },
237 { 82, "set-status" },
238 { 83, "get-status" },
239 { 84, "enumerate-instance" },
240 { 85, "get-instance-info" },
241 { 86, "get-instance-parm" },
242 { 87, "add-superuser" },
243 { 88, "delete-superuser" },
244 { 89, "list-superusers" },
247 { 92, "delete-key" },
248 { 93, "set-cell-name" },
249 { 94, "get-cell-name" },
250 { 95, "get-cell-host" },
251 { 96, "add-cell-host" },
252 { 97, "delete-cell-host" },
253 { 98, "set-t-status" },
254 { 99, "shutdown-all" },
255 { 100, "restart-all" },
256 { 101, "startup-all" },
257 { 102, "set-noauth-flag" },
260 { 105, "start-bozo-install" },
261 { 106, "uninstall" },
262 { 107, "get-dates" },
265 { 110, "set-restart-time" },
266 { 111, "get-restart-time" },
267 { 112, "start-bozo-log" },
269 { 114, "get-instance-strings" },
273 static struct tok ubik_req
[] = {
274 { 10000, "vote-beacon" },
275 { 10001, "vote-debug-old" },
276 { 10002, "vote-sdebug-old" },
277 { 10003, "vote-getsyncsite" },
278 { 10004, "vote-debug" },
279 { 10005, "vote-sdebug" },
280 { 20000, "disk-begin" },
281 { 20001, "disk-commit" },
282 { 20002, "disk-lock" },
283 { 20003, "disk-write" },
284 { 20004, "disk-getversion" },
285 { 20005, "disk-getfile" },
286 { 20006, "disk-sendfile" },
287 { 20007, "disk-abort" },
288 { 20008, "disk-releaselocks" },
289 { 20009, "disk-truncate" },
290 { 20010, "disk-probe" },
291 { 20011, "disk-writev" },
292 { 20012, "disk-interfaceaddr" },
293 { 20013, "disk-setversion" },
297 #define VOTE_LOW 10000
298 #define VOTE_HIGH 10005
299 #define DISK_LOW 20000
300 #define DISK_HIGH 20013
302 static struct tok cb_types
[] = {
309 static struct tok ubik_lock_types
[] = {
316 static char *voltype
[] = { "read-write", "read-only", "backup" };
319 * Cache entries we keep around so we can figure out the RX opcode
320 * numbers for replies. This allows us to make sense of RX reply packets.
323 struct rx_cache_entry
{
324 u_int32_t callnum
; /* Call number (net order) */
325 struct in_addr client
; /* client IP address (net order) */
326 struct in_addr server
; /* server IP address (net order) */
327 int dport
; /* server port (host order) */
328 u_short serviceId
; /* Service identifier (net order) */
329 u_int32_t opcode
; /* RX opcode (host order) */
332 #define RX_CACHE_SIZE 64
334 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
336 static int rx_cache_next
= 0;
337 static int rx_cache_hint
= 0;
338 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
339 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
342 static void fs_print(const u_char
*, int);
343 static void fs_reply_print(const u_char
*, int, int32_t);
344 static void acl_print(u_char
*, u_char
*);
345 static void cb_print(const u_char
*, int);
346 static void cb_reply_print(const u_char
*, int, int32_t);
347 static void prot_print(const u_char
*, int);
348 static void prot_reply_print(const u_char
*, int, int32_t);
349 static void vldb_print(const u_char
*, int);
350 static void vldb_reply_print(const u_char
*, int, int32_t);
351 static void kauth_print(const u_char
*, int);
352 static void kauth_reply_print(const u_char
*, int, int32_t);
353 static void vol_print(const u_char
*, int);
354 static void vol_reply_print(const u_char
*, int, int32_t);
355 static void bos_print(const u_char
*, int);
356 static void bos_reply_print(const u_char
*, int, int32_t);
357 static void ubik_print(const u_char
*, int);
358 static void ubik_reply_print(const u_char
*, int, int32_t);
360 static int is_ubik(u_int32_t
);
363 * Handle the rx-level packet. See if we know what port it's going to so
364 * we can peek at the afs call inside
368 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
371 register struct rx_header
*rxh
;
375 if (snapend
- bp
< sizeof (struct rx_header
)) {
376 printf(" [|rx] (%d)", length
);
380 rxh
= (struct rx_header
*) bp
;
382 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
386 printf(" cid %08x call# %d seq %d ser %d",
387 (int) ntohl(rxh
->cid
),
388 (int) ntohl(rxh
->callNumber
),
389 (int) ntohl(rxh
->seq
),
390 (int) ntohl(rxh
->serial
));
392 printf(" secindex %d serviceid %hu",
393 (int) rxh
->securityIndex
,
394 ntohs(rxh
->serviceId
));
395 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
396 if (rxh
->flags
& rx_flags
[i
].v
) {
403 printf("<%s>", rx_flags
[i
].s
);
409 * Try to handle AFS calls that we know about. Check the destination
410 * port and make sure it's a data packet. Also, make sure the
411 * seq number is 1 (because otherwise it's a continuation packet,
412 * and we can't interpret that). Also, seems that reply packets
413 * do not have the client-init flag set, so we check for that
417 if (rxh
->type
== RX_PACKET_TYPE_DATA
&& ntohl(rxh
->seq
) == 1 &&
418 rxh
->flags
& RX_CLIENT_INITIATED
) {
421 * Insert this call into the call cache table, so we
422 * have a chance to print out replies
425 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
428 case FS_RX_PORT
: /* AFS file service */
429 fs_print(bp
, length
);
431 case CB_RX_PORT
: /* AFS callback service */
432 cb_print(bp
, length
);
434 case PROT_RX_PORT
: /* AFS protection service */
435 prot_print(bp
, length
);
437 case VLDB_RX_PORT
: /* AFS VLDB service */
438 vldb_print(bp
, length
);
440 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
441 kauth_print(bp
, length
);
443 case VOL_RX_PORT
: /* AFS Volume service */
444 vol_print(bp
, length
);
446 case BOS_RX_PORT
: /* AFS BOS service */
447 bos_print(bp
, length
);
454 * If it's a reply (client-init is _not_ set, but seq is one)
455 * then look it up in the cache. If we find it, call the reply
456 * printing functions Note that we handle abort packets here,
457 * because printing out the return code can be useful at times.
460 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
461 ntohl(rxh
->seq
) == 1) ||
462 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
463 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
464 rx_cache_find(rxh
, (const struct ip
*) bp2
,
468 case FS_RX_PORT
: /* AFS file service */
469 fs_reply_print(bp
, length
, opcode
);
471 case CB_RX_PORT
: /* AFS callback service */
472 cb_reply_print(bp
, length
, opcode
);
474 case PROT_RX_PORT
: /* AFS PT service */
475 prot_reply_print(bp
, length
, opcode
);
477 case VLDB_RX_PORT
: /* AFS VLDB service */
478 vldb_reply_print(bp
, length
, opcode
);
480 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
481 kauth_reply_print(bp
, length
, opcode
);
483 case VOL_RX_PORT
: /* AFS Volume service */
484 vol_reply_print(bp
, length
, opcode
);
486 case BOS_RX_PORT
: /* AFS BOS service */
487 bos_reply_print(bp
, length
, opcode
);
495 printf(" (%d)", length
);
499 * Insert an entry into the cache. Taken from print-nfs.c
503 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
506 struct rx_cache_entry
*rxent
;
507 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
509 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
512 rxent
= &rx_cache
[rx_cache_next
];
514 if (++rx_cache_next
>= RX_CACHE_SIZE
)
517 rxent
->callnum
= rxh
->callNumber
;
518 rxent
->client
= ip
->ip_src
;
519 rxent
->server
= ip
->ip_dst
;
520 rxent
->dport
= dport
;
521 rxent
->serviceId
= rxh
->serviceId
;
522 rxent
->opcode
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
526 * Lookup an entry in the cache. Also taken from print-nfs.c
528 * Note that because this is a reply, we're looking at the _source_
533 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
537 struct rx_cache_entry
*rxent
;
538 u_int32_t clip
= ip
->ip_dst
.s_addr
;
539 u_int32_t sip
= ip
->ip_src
.s_addr
;
541 /* Start the search where we last left off */
545 rxent
= &rx_cache
[i
];
546 if (rxent
->callnum
== rxh
->callNumber
&&
547 rxent
->client
.s_addr
== clip
&&
548 rxent
->server
.s_addr
== sip
&&
549 rxent
->serviceId
== rxh
->serviceId
&&
550 rxent
->dport
== sport
) {
552 /* We got a match! */
555 *opcode
= rxent
->opcode
;
558 if (++i
> RX_CACHE_SIZE
)
560 } while (i
!= rx_cache_hint
);
562 /* Our search failed */
567 * These extrememly grody macros handle the printing of various AFS stuff.
570 #define TRUNC(n) if (snapend - bp + 1 <= n) goto trunc;
571 #define FIDOUT() { unsigned long n1, n2, n3; \
572 TRUNC(sizeof(int32_t) * 3); \
573 n1 = ntohl(*((int *) bp)); \
574 bp += sizeof(int32_t); \
575 n2 = ntohl(*((int *) bp)); \
576 bp += sizeof(int32_t); \
577 n3 = ntohl(*((int *) bp)); \
578 bp += sizeof(int32_t); \
579 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
582 #define STROUT(MAX) { int i; \
583 TRUNC(sizeof(int32_t)); \
584 i = (int) ntohl(*((int *) bp)); \
585 bp += sizeof(int32_t); \
587 strncpy(s, bp, min(MAX, i)); \
589 printf(" \"%s\"", s); \
590 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
593 #define INTOUT() { int i; \
594 TRUNC(sizeof(int32_t)); \
595 i = (int) ntohl(*((int *) bp)); \
596 bp += sizeof(int32_t); \
600 #define UINTOUT() { unsigned long i; \
601 TRUNC(sizeof(int32_t)); \
602 i = ntohl(*((int *) bp)); \
603 bp += sizeof(int32_t); \
607 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
608 TRUNC(sizeof(int32_t)); \
609 t = (time_t) ntohl(*((int *) bp)); \
610 bp += sizeof(int32_t); \
611 tm = localtime(&t); \
612 strftime(str, 256, "%Y/%m/%d %T", tm); \
613 printf(" %s", str); \
616 #define STOREATTROUT() { unsigned long mask, i; \
617 TRUNC((sizeof(int32_t)*6)); \
618 mask = ntohl(*((int *) bp)); bp += sizeof(int32_t); \
619 if (mask) printf (" StoreStatus"); \
620 if (mask & 1) { printf(" date"); DATEOUT(); } \
621 else bp += sizeof(int32_t); \
622 i = ntohl(*((int *) bp)); bp += sizeof(int32_t); \
623 if (mask & 2) printf(" owner %lu", i); \
624 i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \
625 if (mask & 4) printf(" group %lu", i); \
626 i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \
627 if (mask & 8) printf(" mode %lo", i & 07777); \
628 i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \
629 if (mask & 16) printf(" segsize %lu", i); \
630 /* undocumented in 3.3 docu */ \
631 if (mask & 1024) printf(" fsync"); \
634 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
635 TRUNC(sizeof(int32_t) * 2); \
636 epoch = ntohl(*((int *) bp)); \
637 bp += sizeof(int32_t); \
638 counter = ntohl(*((int *) bp)); \
639 bp += sizeof(int32_t); \
640 printf(" %d.%d", epoch, counter); \
643 #define AFSUUIDOUT() {u_int32_t temp; int i; \
644 TRUNC(11*sizeof(u_int32_t)); \
645 temp = ntohl(*((int *) bp)); \
646 bp += sizeof(u_int32_t); \
647 printf(" %08x", temp); \
648 temp = ntohl(*((int *) bp)); \
649 bp += sizeof(u_int32_t); \
650 printf("%04x", temp); \
651 temp = ntohl(*((int *) bp)); \
652 bp += sizeof(u_int32_t); \
653 printf("%04x", temp); \
654 for (i = 0; i < 8; i++) { \
655 temp = ntohl(*((int *) bp)); \
656 bp += sizeof(u_int32_t); \
657 printf("%02x", (unsigned char) temp); \
662 * This is the sickest one of all
665 #define VECOUT(MAX) { char *sp; \
667 TRUNC(MAX * sizeof(int32_t)); \
669 for (k = 0; k < MAX; k++) { \
670 *sp++ = (char) ntohl(*((int *) bp)); \
671 bp += sizeof(int32_t); \
674 printf(" \"%s\"", s); \
678 * Handle calls to the AFS file service (fs)
682 fs_print(register const u_char
*bp
, int length
)
688 if (length
<= sizeof(struct rx_header
))
691 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
696 * Print out the afs call we're invoking. The table used here was
697 * gleaned from fsint/afsint.xg
700 fs_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
702 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
705 * Print out arguments to some of the AFS calls. This stuff is
709 bp
+= sizeof(struct rx_header
) + 4;
712 * Sigh. This is gross. Ritchie forgive me.
716 case 130: /* Fetch data */
723 case 131: /* Fetch ACL */
724 case 132: /* Fetch Status */
725 case 143: /* Old set lock */
726 case 144: /* Old extend lock */
727 case 145: /* Old release lock */
728 case 156: /* Set lock */
729 case 157: /* Extend lock */
730 case 158: /* Release lock */
733 case 135: /* Store status */
737 case 133: /* Store data */
747 case 134: /* Store ACL */
749 char a
[AFSOPAQUEMAX
];
752 i
= ntohl(*((int *) bp
));
753 bp
+= sizeof(int32_t);
755 strncpy(a
, bp
, min(AFSOPAQUEMAX
, i
));
757 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
760 case 137: /* Create file */
761 case 141: /* MakeDir */
766 case 136: /* Remove file */
767 case 142: /* Remove directory */
771 case 138: /* Rename file */
779 case 139: /* Symlink */
791 case 148: /* Get volume info */
794 case 149: /* Get volume stats */
795 case 150: /* Set volume stats */
799 case 154: /* New get volume info */
803 case 155: /* Bulk stat */
807 j
= ntohl(*((int *) bp
));
808 bp
+= sizeof(int32_t);
810 for (i
= 0; i
< j
; i
++) {
829 * Handle replies to the AFS file service
833 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
837 struct rx_header
*rxh
;
839 if (length
<= sizeof(struct rx_header
))
842 rxh
= (struct rx_header
*) bp
;
845 * Print out the afs call we're invoking. The table used here was
846 * gleaned from fsint/afsint.xg
849 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
851 bp
+= sizeof(struct rx_header
);
854 * If it was a data packet, interpret the response
857 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
859 case 131: /* Fetch ACL */
861 char a
[AFSOPAQUEMAX
];
863 i
= ntohl(*((int *) bp
));
864 bp
+= sizeof(int32_t);
866 strncpy(a
, bp
, min(AFSOPAQUEMAX
, i
));
868 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
871 case 137: /* Create file */
872 case 141: /* MakeDir */
876 case 151: /* Get root volume */
877 printf(" root volume");
880 case 153: /* Get time */
888 * Otherwise, just print out the return code
901 * Print out an AFS ACL string. An AFS ACL is a string that has the
904 * <positive> <negative>
908 * "positive" and "negative" are integers which contain the number of
909 * positive and negative ACL's in the string. The uid/aclbits pair are
910 * ASCII strings containing the UID/PTS record and and a ascii number
911 * representing a logical OR of all the ACL permission bits
915 acl_print(u_char
*s
, u_char
*end
)
921 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
930 * This wacky order preserves the order used by the "fs" command
933 #define ACLOUT(acl) \
934 if (acl & PRSFS_READ) \
936 if (acl & PRSFS_LOOKUP) \
938 if (acl & PRSFS_INSERT) \
940 if (acl & PRSFS_DELETE) \
942 if (acl & PRSFS_WRITE) \
944 if (acl & PRSFS_LOCK) \
946 if (acl & PRSFS_ADMINISTER) \
949 for (i
= 0; i
< pos
; i
++) {
950 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
953 printf(" +{%s ", user
);
960 for (i
= 0; i
< neg
; i
++) {
961 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
964 printf(" -{%s ", user
);
975 * Handle calls to the AFS callback service
979 cb_print(register const u_char
*bp
, int length
)
984 if (length
<= sizeof(struct rx_header
))
987 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
992 * Print out the afs call we're invoking. The table used here was
993 * gleaned from fsint/afscbint.xg
996 cb_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
998 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1000 bp
+= sizeof(struct rx_header
) + 4;
1003 * Print out the afs call we're invoking. The table used here was
1004 * gleaned from fsint/afscbint.xg
1008 case 204: /* Callback */
1012 j
= ntohl(*((int *) bp
));
1013 bp
+= sizeof(int32_t);
1015 for (i
= 0; i
< j
; i
++) {
1024 j
= ntohl(*((int *) bp
));
1025 bp
+= sizeof(int32_t);
1030 for (i
= 0; i
< j
; i
++) {
1036 t
= ntohl(*((int *) bp
));
1037 bp
+= sizeof(int32_t);
1038 tok2str(cb_types
, "type %d", t
);
1057 * Handle replies to the AFS Callback Service
1061 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1063 struct rx_header
*rxh
;
1065 if (length
<= sizeof(struct rx_header
))
1068 rxh
= (struct rx_header
*) bp
;
1071 * Print out the afs call we're invoking. The table used here was
1072 * gleaned from fsint/afscbint.xg
1075 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1077 bp
+= sizeof(struct rx_header
);
1080 * If it was a data packet, interpret the response.
1083 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1085 case 213: /* InitCallBackState3 */
1093 * Otherwise, just print out the return code
1106 * Handle calls to the AFS protection database server
1110 prot_print(register const u_char
*bp
, int length
)
1116 if (length
<= sizeof(struct rx_header
))
1119 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1124 * Print out the afs call we're invoking. The table used here was
1125 * gleaned from ptserver/ptint.xg
1128 pt_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1132 if (is_ubik(pt_op
)) {
1133 ubik_print(bp
, length
);
1137 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1140 * Decode some of the arguments to the PT calls
1143 bp
+= sizeof(struct rx_header
) + 4;
1146 case 500: /* I New User */
1153 case 501: /* Where is it */
1154 case 506: /* Delete */
1155 case 508: /* Get CPS */
1156 case 512: /* List entry */
1157 case 514: /* List elements */
1158 case 517: /* List owned */
1159 case 518: /* Get CPS2 */
1160 case 519: /* Get host CPS */
1164 case 502: /* Dump entry */
1168 case 503: /* Add to group */
1169 case 507: /* Remove from group */
1170 case 515: /* Is a member of? */
1176 case 504: /* Name to ID */
1180 j
= ntohl(*((int *) bp
));
1181 bp
+= sizeof(int32_t);
1184 * Who designed this chicken-shit protocol?
1186 * Each character is stored as a 32-bit
1190 for (i
= 0; i
< j
; i
++) {
1197 case 505: /* Id to name */
1202 i
= ntohl(*((int *) bp
));
1203 bp
+= sizeof(int32_t);
1204 for (j
= 0; j
< i
; j
++)
1210 case 509: /* New entry */
1217 case 511: /* Set max */
1223 case 513: /* Change entry */
1232 case 520: /* Update entry */
1249 * Handle replies to the AFS protection service
1253 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1255 struct rx_header
*rxh
;
1259 if (length
< sizeof(struct rx_header
))
1262 rxh
= (struct rx_header
*) bp
;
1265 * Print out the afs call we're invoking. The table used here was
1266 * gleaned from ptserver/ptint.xg. Check to see if it's a
1267 * Ubik call, however.
1272 if (is_ubik(opcode
)) {
1273 ubik_reply_print(bp
, length
, opcode
);
1277 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1279 bp
+= sizeof(struct rx_header
);
1282 * If it was a data packet, interpret the response
1285 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1287 case 504: /* Name to ID */
1292 i
= ntohl(*((int *) bp
));
1293 bp
+= sizeof(int32_t);
1294 for (j
= 0; j
< i
; j
++)
1300 case 505: /* ID to name */
1304 j
= ntohl(*((int *) bp
));
1305 bp
+= sizeof(int32_t);
1308 * Who designed this chicken-shit protocol?
1310 * Each character is stored as a 32-bit
1314 for (i
= 0; i
< j
; i
++) {
1321 case 508: /* Get CPS */
1322 case 514: /* List elements */
1323 case 517: /* List owned */
1324 case 518: /* Get CPS2 */
1325 case 519: /* Get host CPS */
1329 j
= ntohl(*((int *) bp
));
1330 bp
+= sizeof(int32_t);
1331 for (i
= 0; i
< j
; i
++) {
1338 case 510: /* List max */
1349 * Otherwise, just print out the return code
1362 * Handle calls to the AFS volume location database service
1366 vldb_print(register const u_char
*bp
, int length
)
1372 if (length
<= sizeof(struct rx_header
))
1375 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1380 * Print out the afs call we're invoking. The table used here was
1381 * gleaned from vlserver/vldbint.xg
1384 vldb_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1388 if (is_ubik(vldb_op
)) {
1389 ubik_print(bp
, length
);
1392 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1395 * Decode some of the arguments to the VLDB calls
1398 bp
+= sizeof(struct rx_header
) + 4;
1401 case 501: /* Create new volume */
1402 case 517: /* Create entry N */
1405 case 502: /* Delete entry */
1406 case 503: /* Get entry by ID */
1407 case 507: /* Update entry */
1408 case 508: /* Set lock */
1409 case 509: /* Release lock */
1410 case 518: /* Get entry by ID N */
1413 TRUNC(sizeof(int32_t));
1414 i
= ntohl(*((int *) bp
));
1415 bp
+= sizeof(int32_t);
1417 printf(" type %s", voltype
[i
]);
1419 case 504: /* Get entry by name */
1420 case 519: /* Get entry by name N */
1421 case 524: /* Update entry by name */
1422 case 527: /* Get entry by name U */
1425 case 505: /* Get new vol id */
1429 case 506: /* Replace entry */
1430 case 520: /* Replace entry N */
1433 TRUNC(sizeof(int32_t));
1434 i
= ntohl(*((int *) bp
));
1435 bp
+= sizeof(int32_t);
1437 printf(" type %s", voltype
[i
]);
1440 case 510: /* List entry */
1441 case 521: /* List entry N */
1456 * Handle replies to the AFS volume location database service
1460 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1462 struct rx_header
*rxh
;
1466 if (length
< sizeof(struct rx_header
))
1469 rxh
= (struct rx_header
*) bp
;
1472 * Print out the afs call we're invoking. The table used here was
1473 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1474 * Ubik call, however.
1479 if (is_ubik(opcode
)) {
1480 ubik_reply_print(bp
, length
, opcode
);
1484 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1486 bp
+= sizeof(struct rx_header
);
1489 * If it was a data packet, interpret the response
1492 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1494 case 510: /* List entry */
1497 printf(" nextindex");
1499 case 503: /* Get entry by id */
1500 case 504: /* Get entry by name */
1501 { unsigned long nservers
, j
;
1503 TRUNC(sizeof(int32_t));
1504 bp
+= sizeof(int32_t);
1505 printf(" numservers");
1506 TRUNC(sizeof(int32_t));
1507 nservers
= ntohl(*((int *) bp
));
1508 bp
+= sizeof(int32_t);
1509 printf(" %lu", nservers
);
1511 for (i
= 0; i
< 8; i
++) {
1512 TRUNC(sizeof(int32_t));
1515 inet_ntoa(*((struct in_addr
*) bp
)));
1516 bp
+= sizeof(int32_t);
1518 printf(" partitions");
1519 for (i
= 0; i
< 8; i
++) {
1520 TRUNC(sizeof(int32_t));
1521 j
= ntohl(*((int *) bp
));
1522 if (i
< nservers
&& j
<= 26)
1523 printf(" %c", 'a' + (int)j
);
1524 else if (i
< nservers
)
1526 bp
+= sizeof(int32_t);
1528 TRUNC(8 * sizeof(int32_t));
1529 bp
+= 8 * sizeof(int32_t);
1538 case 505: /* Get new volume ID */
1542 case 521: /* List entry */
1543 case 529: /* List entry U */
1546 printf(" nextindex");
1548 case 518: /* Get entry by ID N */
1549 case 519: /* Get entry by name N */
1550 { unsigned long nservers
, j
;
1552 printf(" numservers");
1553 TRUNC(sizeof(int32_t));
1554 nservers
= ntohl(*((int *) bp
));
1555 bp
+= sizeof(int32_t);
1556 printf(" %lu", nservers
);
1558 for (i
= 0; i
< 13; i
++) {
1559 TRUNC(sizeof(int32_t));
1562 inet_ntoa(*((struct in_addr
*) bp
)));
1563 bp
+= sizeof(int32_t);
1565 printf(" partitions");
1566 for (i
= 0; i
< 13; i
++) {
1567 TRUNC(sizeof(int32_t));
1568 j
= ntohl(*((int *) bp
));
1569 if (i
< nservers
&& j
<= 26)
1570 printf(" %c", 'a' + (int)j
);
1571 else if (i
< nservers
)
1573 bp
+= sizeof(int32_t);
1575 TRUNC(13 * sizeof(int32_t));
1576 bp
+= 13 * sizeof(int32_t);
1585 case 526: /* Get entry by ID U */
1586 case 527: /* Get entry by name U */
1587 { unsigned long nservers
, j
;
1589 printf(" numservers");
1590 TRUNC(sizeof(int32_t));
1591 nservers
= ntohl(*((int *) bp
));
1592 bp
+= sizeof(int32_t);
1593 printf(" %lu", nservers
);
1595 for (i
= 0; i
< 13; i
++) {
1606 printf(" partitions");
1607 for (i
= 0; i
< 13; i
++) {
1608 TRUNC(sizeof(int32_t));
1609 j
= ntohl(*((int *) bp
));
1610 if (i
< nservers
&& j
<= 26)
1611 printf(" %c", 'a' + (int)j
);
1612 else if (i
< nservers
)
1614 bp
+= sizeof(int32_t);
1616 TRUNC(13 * sizeof(int32_t));
1617 bp
+= 13 * sizeof(int32_t);
1631 * Otherwise, just print out the return code
1644 * Handle calls to the AFS Kerberos Authentication service
1648 kauth_print(register const u_char
*bp
, int length
)
1653 if (length
<= sizeof(struct rx_header
))
1656 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1661 * Print out the afs call we're invoking. The table used here was
1662 * gleaned from kauth/kauth.rg
1665 kauth_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1669 if (is_ubik(kauth_op
)) {
1670 ubik_print(bp
, length
);
1675 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1678 * Decode some of the arguments to the KA calls
1681 bp
+= sizeof(struct rx_header
) + 4;
1684 case 1: /* Authenticate old */;
1685 case 21: /* Authenticate */
1686 case 22: /* Authenticate-V2 */
1687 case 2: /* Change PW */
1688 case 5: /* Set fields */
1689 case 6: /* Create user */
1690 case 7: /* Delete user */
1691 case 8: /* Get entry */
1692 case 14: /* Unlock */
1693 case 15: /* Lock status */
1694 printf(" principal");
1698 case 3: /* GetTicket-old */
1699 case 23: /* GetTicket */
1706 TRUNC(sizeof(int32_t));
1707 i
= (int) ntohl(*((int *) bp
));
1708 bp
+= sizeof(int32_t);
1711 printf(" principal");
1716 case 4: /* Set Password */
1717 printf(" principal");
1723 case 12: /* Get password */
1734 printf(" [|kauth]");
1738 * Handle replies to the AFS Kerberos Authentication Service
1742 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1744 struct rx_header
*rxh
;
1746 if (length
<= sizeof(struct rx_header
))
1749 rxh
= (struct rx_header
*) bp
;
1752 * Print out the afs call we're invoking. The table used here was
1753 * gleaned from kauth/kauth.rg
1758 if (is_ubik(opcode
)) {
1759 ubik_reply_print(bp
, length
, opcode
);
1763 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1765 bp
+= sizeof(struct rx_header
);
1768 * If it was a data packet, interpret the response.
1771 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1772 /* Well, no, not really. Leave this for later */
1776 * Otherwise, just print out the return code
1785 printf(" [|kauth]");
1789 * Handle calls to the AFS Volume location service
1793 vol_print(register const u_char
*bp
, int length
)
1797 if (length
<= sizeof(struct rx_header
))
1800 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1805 * Print out the afs call we're invoking. The table used here was
1806 * gleaned from volser/volint.xg
1809 vol_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1811 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1814 * Normally there would be a switch statement here to decode the
1815 * arguments to the AFS call, but since I don't have access to
1816 * an AFS server (yet) and I'm not an AFS admin, I can't
1817 * test any of these calls. Leave this blank for now.
1827 * Handle replies to the AFS Volume Service
1831 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1833 struct rx_header
*rxh
;
1835 if (length
<= sizeof(struct rx_header
))
1838 rxh
= (struct rx_header
*) bp
;
1841 * Print out the afs call we're invoking. The table used here was
1842 * gleaned from volser/volint.xg
1845 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
1847 bp
+= sizeof(struct rx_header
);
1850 * If it was a data packet, interpret the response.
1853 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1854 /* Well, no, not really. Leave this for later */
1858 * Otherwise, just print out the return code
1871 * Handle calls to the AFS BOS service
1875 bos_print(register const u_char
*bp
, int length
)
1880 if (length
<= sizeof(struct rx_header
))
1883 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1888 * Print out the afs call we're invoking. The table used here was
1889 * gleaned from bozo/bosint.xg
1892 bos_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1894 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
1897 * Decode some of the arguments to the BOS calls
1900 bp
+= sizeof(struct rx_header
) + 4;
1903 case 80: /* Create B node */
1906 printf(" instance");
1909 case 81: /* Delete B node */
1910 case 83: /* Get status */
1911 case 85: /* Get instance info */
1912 case 87: /* Add super user */
1913 case 88: /* Delete super user */
1914 case 93: /* Set cell name */
1915 case 96: /* Add cell host */
1916 case 97: /* Delete cell host */
1917 case 104: /* Restart */
1918 case 106: /* Uninstall */
1919 case 108: /* Exec */
1920 case 112: /* Getlog */
1921 case 114: /* Get instance strings */
1924 case 82: /* Set status */
1925 case 98: /* Set T status */
1930 case 86: /* Get instance parm */
1935 case 84: /* Enumerate instance */
1936 case 89: /* List super users */
1937 case 90: /* List keys */
1938 case 91: /* Add key */
1939 case 92: /* Delete key */
1940 case 95: /* Get cell host */
1943 case 105: /* Install */
1963 * Handle replies to the AFS BOS Service
1967 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1969 struct rx_header
*rxh
;
1971 if (length
<= sizeof(struct rx_header
))
1974 rxh
= (struct rx_header
*) bp
;
1977 * Print out the afs call we're invoking. The table used here was
1978 * gleaned from volser/volint.xg
1981 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
1983 bp
+= sizeof(struct rx_header
);
1986 * If it was a data packet, interpret the response.
1989 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1990 /* Well, no, not really. Leave this for later */
1994 * Otherwise, just print out the return code
2007 * Check to see if this is a Ubik opcode.
2011 is_ubik(u_int32_t opcode
)
2013 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2014 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2021 * Handle Ubik opcodes to any one of the replicated database services
2025 ubik_print(register const u_char
*bp
, int length
)
2031 * Print out the afs call we're invoking. The table used here was
2032 * gleaned from ubik/ubik_int.xg
2035 ubik_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
2037 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2040 * Decode some of the arguments to the Ubik calls
2043 bp
+= sizeof(struct rx_header
) + 4;
2046 case 10000: /* Beacon */
2048 temp
= ntohl(*((int *) bp
));
2049 bp
+= sizeof(int32_t);
2050 printf(" syncsite %s", temp
? "yes" : "no");
2051 printf(" votestart");
2053 printf(" dbversion");
2058 case 10003: /* Get sync site */
2062 case 20000: /* Begin */
2063 case 20001: /* Commit */
2064 case 20007: /* Abort */
2065 case 20008: /* Release locks */
2066 case 20010: /* Writev */
2070 case 20002: /* Lock */
2079 temp
= ntohl(*((int *) bp
));
2080 bp
+= sizeof(int32_t);
2081 tok2str(ubik_lock_types
, "type %d", temp
);
2083 case 20003: /* Write */
2091 case 20005: /* Get file */
2095 case 20006: /* Send file */
2100 printf(" dbversion");
2103 case 20009: /* Truncate */
2111 case 20012: /* Set version */
2114 printf(" oldversion");
2116 printf(" newversion");
2130 * Handle Ubik replies to any one of the replicated database services
2134 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2136 struct rx_header
*rxh
;
2138 if (length
< sizeof(struct rx_header
))
2141 rxh
= (struct rx_header
*) bp
;
2144 * Print out the ubik call we're invoking. This table was gleaned
2145 * from ubik/ubik_int.xg
2148 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2150 bp
+= sizeof(struct rx_header
);
2153 * If it was a data packet, print out the arguments to the Ubik calls
2156 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2158 case 10000: /* Beacon */
2161 case 20004: /* Get version */
2162 printf(" dbversion");
2170 * Otherwise, print out "yes" it it was a beacon packet (because
2171 * that's how yes votes are returned, go figure), otherwise
2172 * just print out the error code.
2177 case 10000: /* Beacon */
2178 printf(" vote yes until");