]>
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.3 1999-11-17 22:19:41 assar Exp $";
21 #include <sys/param.h>
23 #include <sys/types.h>
24 #include <sys/socket.h>
25 #include <netinet/in.h>
26 #include <netinet/in_systm.h>
27 #include <netinet/ip.h>
28 #include <arpa/inet.h>
30 #include "interface.h"
31 #include "addrtoname.h"
33 #undef NOERROR /* Solaris sucks */
34 #include <arpa/nameser.h>
38 static struct tok rx_types
[] = {
39 { RX_PACKET_TYPE_DATA
, "data" },
40 { RX_PACKET_TYPE_ACK
, "ack" },
41 { RX_PACKET_TYPE_BUSY
, "busy" },
42 { RX_PACKET_TYPE_ABORT
, "abort" },
43 { RX_PACKET_TYPE_ACKALL
, "ackall" },
44 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
45 { RX_PACKET_TYPE_RESPONSE
, "response" },
46 { RX_PACKET_TYPE_DEBUG
, "debug" },
47 { RX_PACKET_TYPE_PARAMS
, "params" },
48 { RX_PACKET_TYPE_VERSION
, "version" },
52 static struct tok rx_flags
[] = {
53 { RX_CLIENT_INITIATED
, "client-init" },
54 { RX_REQUEST_ACK
, "req-ack" },
55 { RX_LAST_PACKET
, "last-pckt" },
56 { RX_MORE_PACKETS
, "more-pckts" },
57 { RX_FREE_PACKET
, "free-pckt" }
60 static struct tok fs_req
[] = {
61 { 130, "fetch-data" },
63 { 132, "fetch-status" },
64 { 133, "store-data" },
66 { 135, "store-status" },
67 { 136, "remove-file" },
68 { 137, "create-file" },
74 { 143, "oldsetlock" },
75 { 144, "oldextlock" },
76 { 145, "oldrellock" },
79 { 148, "get-vlinfo" },
80 { 149, "get-vlstats" },
81 { 150, "set-vlstats" },
82 { 151, "get-rootvl" },
83 { 152, "check-token" },
85 { 154, "nget-vlinfo" },
92 { 161, "dfs-lookup" },
93 { 162, "dfs-flushcps" },
94 { 163, "dfs-symlink" },
98 static struct tok cb_req
[] = {
107 { 212, "whoareyou" },
109 { 214, "probeuuid" },
113 static struct tok pt_req
[] = {
115 { 501, "where-is-it" },
116 { 502, "dump-entry" },
117 { 503, "add-to-group" },
118 { 504, "name-to-id" },
119 { 505, "id-to-name" },
121 { 507, "remove-from-group" },
123 { 509, "new-entry" },
126 { 512, "list-entry" },
127 { 513, "change-entry" },
128 { 514, "list-elements" },
129 { 515, "same-mbr-of" },
130 { 516, "set-fld-sentry" },
131 { 517, "list-owned" },
133 { 519, "get-host-cps" },
134 { 520, "update-entry" },
138 static struct tok vldb_req
[] = {
139 { 501, "create-entry" },
140 { 502, "delete-entry" },
141 { 503, "get-entry-by-id" },
142 { 504, "get-entry-by-name" },
143 { 505, "get-new-volume-id" },
144 { 506, "replace-entry" },
145 { 507, "update-entry" },
147 { 509, "releaselock" },
148 { 510, "list-entry" },
149 { 511, "list-attrib" },
150 { 512, "linked-list" },
151 { 513, "get-stats" },
153 { 515, "get-addrs" },
154 { 516, "change-addr" },
155 { 517, "create-entry-n" },
156 { 518, "get-entry-by-id-n" },
157 { 519, "get-entry-by-name-n" },
158 { 520, "replace-entry-n" },
159 { 521, "list-entry-n" },
160 { 522, "list-attrib-n" },
161 { 523, "linked-list-n" },
162 { 524, "update-entry-by-name" },
163 { 525, "create-entry-u" },
164 { 526, "get-entry-by-id-u" },
165 { 527, "get-entry-by-name-u" },
166 { 528, "replace-entry-u" },
167 { 529, "list-entry-u" },
168 { 530, "list-attrib-u" },
169 { 531, "linked-list-u" },
171 { 533, "get-addrs-u" },
175 static struct tok kauth_req
[] = {
177 { 21, "authenticate" },
178 { 22, "authenticate-v2" },
180 { 3, "get-ticket-old" },
181 { 23, "get-ticket" },
184 { 6, "create-user" },
185 { 7, "delete-user" },
191 { 13, "get-random-key" },
193 { 15, "lock-status" },
197 static struct tok vol_req
[] = {
198 { 100, "create-volume" },
199 { 101, "delete-volume" },
202 { 104, "end-trans" },
204 { 106, "set-flags" },
205 { 107, "get-flags" },
206 { 108, "trans-create" },
208 { 110, "get-nth-volume" },
209 { 111, "set-forwarding" },
211 { 113, "get-status" },
212 { 114, "sig-restore" },
213 { 115, "list-partitions" },
214 { 116, "list-volumes" },
215 { 117, "set-id-types" },
217 { 119, "partition-info" },
219 { 121, "list-one-volume" },
222 { 124, "x-list-volumes" },
223 { 125, "x-list-one-volume" },
225 { 127, "x-list-partitions" },
226 { 128, "forward-multiple" },
230 static struct tok bos_req
[] = {
231 { 80, "create-bnode" },
232 { 81, "delete-bnode" },
233 { 82, "set-status" },
234 { 83, "get-status" },
235 { 84, "enumerate-instance" },
236 { 85, "get-instance-info" },
237 { 86, "get-instance-parm" },
238 { 87, "add-superuser" },
239 { 88, "delete-superuser" },
240 { 89, "list-superusers" },
243 { 92, "delete-key" },
244 { 93, "set-cell-name" },
245 { 94, "get-cell-name" },
246 { 95, "get-cell-host" },
247 { 96, "add-cell-host" },
248 { 97, "delete-cell-host" },
249 { 98, "set-t-status" },
250 { 99, "shutdown-all" },
251 { 100, "restart-all" },
252 { 101, "startup-all" },
253 { 102, "set-noauth-flag" },
256 { 105, "start-bozo-install" },
257 { 106, "uninstall" },
258 { 107, "get-dates" },
261 { 110, "set-restart-time" },
262 { 111, "get-restart-time" },
263 { 112, "start-bozo-log" },
265 { 114, "get-instance-strings" },
269 static struct tok ubik_req
[] = {
270 { 10000, "vote-beacon" },
271 { 10001, "vote-debug-old" },
272 { 10002, "vote-sdebug-old" },
273 { 10003, "vote-getsyncsite" },
274 { 10004, "vote-debug" },
275 { 10005, "vote-sdebug" },
276 { 20000, "disk-begin" },
277 { 20001, "disk-commit" },
278 { 20002, "disk-lock" },
279 { 20003, "disk-write" },
280 { 20004, "disk-getversion" },
281 { 20005, "disk-getfile" },
282 { 20006, "disk-sendfile" },
283 { 20007, "disk-abort" },
284 { 20008, "disk-releaselocks" },
285 { 20009, "disk-truncate" },
286 { 20010, "disk-probe" },
287 { 20011, "disk-writev" },
288 { 20012, "disk-interfaceaddr" },
289 { 20013, "disk-setversion" },
293 #define VOTE_LOW 10000
294 #define VOTE_HIGH 10005
295 #define DISK_LOW 20000
296 #define DISK_HIGH 20013
298 static struct tok cb_types
[] = {
305 static struct tok ubik_lock_types
[] = {
312 static char *voltype
[] = { "read-write", "read-only", "backup" };
315 * Cache entries we keep around so we can figure out the RX opcode
316 * numbers for replies. This allows us to make sense of RX reply packets.
319 struct rx_cache_entry
{
320 u_int32_t callnum
; /* Call number (net order) */
321 struct in_addr client
; /* client IP address (net order) */
322 struct in_addr server
; /* server IP address (net order) */
323 int dport
; /* server port (host order) */
324 u_short serviceId
; /* Service identifier (net order) */
325 u_int32_t opcode
; /* RX opcode (host order) */
328 #define RX_CACHE_SIZE 64
330 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
332 static int rx_cache_next
= 0;
333 static int rx_cache_hint
= 0;
334 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
335 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
338 static void fs_print(const u_char
*, int);
339 static void fs_reply_print(const u_char
*, int, int32_t);
340 static void acl_print(u_char
*, u_char
*);
341 static void cb_print(const u_char
*, int);
342 static void cb_reply_print(const u_char
*, int, int32_t);
343 static void prot_print(const u_char
*, int);
344 static void prot_reply_print(const u_char
*, int, int32_t);
345 static void vldb_print(const u_char
*, int);
346 static void vldb_reply_print(const u_char
*, int, int32_t);
347 static void kauth_print(const u_char
*, int);
348 static void kauth_reply_print(const u_char
*, int, int32_t);
349 static void vol_print(const u_char
*, int);
350 static void vol_reply_print(const u_char
*, int, int32_t);
351 static void bos_print(const u_char
*, int);
352 static void bos_reply_print(const u_char
*, int, int32_t);
353 static void ubik_print(const u_char
*, int);
354 static void ubik_reply_print(const u_char
*, int, int32_t);
356 static int is_ubik(u_int32_t
);
359 * Handle the rx-level packet. See if we know what port it's going to so
360 * we can peek at the afs call inside
364 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
367 register struct rx_header
*rxh
;
371 if (snapend
- bp
< sizeof (struct rx_header
)) {
372 printf(" [|rx] (%d)", length
);
376 rxh
= (struct rx_header
*) bp
;
378 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
382 printf(" cid %08x call# %d seq %d ser %d",
383 (int) ntohl(rxh
->cid
),
384 (int) ntohl(rxh
->callNumber
),
385 (int) ntohl(rxh
->seq
),
386 (int) ntohl(rxh
->serial
));
388 printf(" secindex %d serviceid %hu",
389 (int) rxh
->securityIndex
,
390 ntohs(rxh
->serviceId
));
391 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
392 if (rxh
->flags
& rx_flags
[i
].v
) {
399 printf("<%s>", rx_flags
[i
].s
);
405 * Try to handle AFS calls that we know about. Check the destination
406 * port and make sure it's a data packet. Also, make sure the
407 * seq number is 1 (because otherwise it's a continuation packet,
408 * and we can't interpret that). Also, seems that reply packets
409 * do not have the client-init flag set, so we check for that
413 if (rxh
->type
== RX_PACKET_TYPE_DATA
&& ntohl(rxh
->seq
) == 1 &&
414 rxh
->flags
& RX_CLIENT_INITIATED
) {
417 * Insert this call into the call cache table, so we
418 * have a chance to print out replies
421 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
424 case FS_RX_PORT
: /* AFS file service */
425 fs_print(bp
, length
);
427 case CB_RX_PORT
: /* AFS callback service */
428 cb_print(bp
, length
);
430 case PROT_RX_PORT
: /* AFS protection service */
431 prot_print(bp
, length
);
433 case VLDB_RX_PORT
: /* AFS VLDB service */
434 vldb_print(bp
, length
);
436 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
437 kauth_print(bp
, length
);
439 case VOL_RX_PORT
: /* AFS Volume service */
440 vol_print(bp
, length
);
442 case BOS_RX_PORT
: /* AFS BOS service */
443 bos_print(bp
, length
);
450 * If it's a reply (client-init is _not_ set, but seq is one)
451 * then look it up in the cache. If we find it, call the reply
452 * printing functions Note that we handle abort packets here,
453 * because printing out the return code can be useful at times.
456 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
457 ntohl(rxh
->seq
) == 1) ||
458 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
459 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
460 rx_cache_find(rxh
, (const struct ip
*) bp2
,
464 case FS_RX_PORT
: /* AFS file service */
465 fs_reply_print(bp
, length
, opcode
);
467 case CB_RX_PORT
: /* AFS callback service */
468 cb_reply_print(bp
, length
, opcode
);
470 case PROT_RX_PORT
: /* AFS PT service */
471 prot_reply_print(bp
, length
, opcode
);
473 case VLDB_RX_PORT
: /* AFS VLDB service */
474 vldb_reply_print(bp
, length
, opcode
);
476 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
477 kauth_reply_print(bp
, length
, opcode
);
479 case VOL_RX_PORT
: /* AFS Volume service */
480 vol_reply_print(bp
, length
, opcode
);
482 case BOS_RX_PORT
: /* AFS BOS service */
483 bos_reply_print(bp
, length
, opcode
);
491 printf(" (%d)", length
);
495 * Insert an entry into the cache. Taken from print-nfs.c
499 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
502 struct rx_cache_entry
*rxent
;
503 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
505 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
508 rxent
= &rx_cache
[rx_cache_next
];
510 if (++rx_cache_next
>= RX_CACHE_SIZE
)
513 rxent
->callnum
= rxh
->callNumber
;
514 rxent
->client
= ip
->ip_src
;
515 rxent
->server
= ip
->ip_dst
;
516 rxent
->dport
= dport
;
517 rxent
->serviceId
= rxh
->serviceId
;
518 rxent
->opcode
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
522 * Lookup an entry in the cache. Also taken from print-nfs.c
524 * Note that because this is a reply, we're looking at the _source_
529 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
533 struct rx_cache_entry
*rxent
;
534 u_int32_t clip
= ip
->ip_dst
.s_addr
;
535 u_int32_t sip
= ip
->ip_src
.s_addr
;
537 /* Start the search where we last left off */
541 rxent
= &rx_cache
[i
];
542 if (rxent
->callnum
== rxh
->callNumber
&&
543 rxent
->client
.s_addr
== clip
&&
544 rxent
->server
.s_addr
== sip
&&
545 rxent
->serviceId
== rxh
->serviceId
&&
546 rxent
->dport
== sport
) {
548 /* We got a match! */
551 *opcode
= rxent
->opcode
;
554 if (++i
> RX_CACHE_SIZE
)
556 } while (i
!= rx_cache_hint
);
558 /* Our search failed */
563 * These extrememly grody macros handle the printing of various AFS stuff.
566 #define TRUNC(n) if (snapend - bp + 1 <= n) goto trunc;
567 #define FIDOUT() { unsigned long n1, n2, n3; \
568 TRUNC(sizeof(int32_t) * 3); \
569 n1 = ntohl(*((int *) bp)); \
570 bp += sizeof(int32_t); \
571 n2 = ntohl(*((int *) bp)); \
572 bp += sizeof(int32_t); \
573 n3 = ntohl(*((int *) bp)); \
574 bp += sizeof(int32_t); \
575 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
578 #define STROUT(MAX) { int i; \
579 TRUNC(sizeof(int32_t)); \
580 i = (int) ntohl(*((int *) bp)); \
581 bp += sizeof(int32_t); \
583 strncpy(s, bp, min(MAX, i)); \
585 printf(" \"%s\"", s); \
586 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
589 #define INTOUT() { int i; \
590 TRUNC(sizeof(int32_t)); \
591 i = (int) ntohl(*((int *) bp)); \
592 bp += sizeof(int32_t); \
596 #define UINTOUT() { unsigned long i; \
597 TRUNC(sizeof(int32_t)); \
598 i = ntohl(*((int *) bp)); \
599 bp += sizeof(int32_t); \
603 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
604 TRUNC(sizeof(int32_t)); \
605 t = (time_t) ntohl(*((int *) bp)); \
606 bp += sizeof(int32_t); \
607 tm = localtime(&t); \
608 strftime(str, 256, "%Y/%m/%d %T", tm); \
609 printf(" %s", str); \
612 #define STOREATTROUT() { unsigned long mask, i; \
613 TRUNC((sizeof(int32_t)*6)); \
614 mask = ntohl(*((int *) bp)); bp += sizeof(int32_t); \
615 if (mask) printf (" StoreStatus"); \
616 if (mask & 1) { printf(" date"); DATEOUT(); } \
617 else bp += sizeof(int32_t); \
618 i = ntohl(*((int *) bp)); bp += sizeof(int32_t); \
619 if (mask & 2) printf(" owner %lu", i); \
620 i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \
621 if (mask & 4) printf(" group %lu", i); \
622 i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \
623 if (mask & 8) printf(" mode %lo", i & 07777); \
624 i = ntohl(*((int32_t *) bp)); bp += sizeof(int32_t); \
625 if (mask & 16) printf(" segsize %lu", i); \
626 /* undocumented in 3.3 docu */ \
627 if (mask & 1024) printf(" fsync"); \
630 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
631 TRUNC(sizeof(int32_t) * 2); \
632 epoch = ntohl(*((int *) bp)); \
633 bp += sizeof(int32_t); \
634 counter = ntohl(*((int *) bp)); \
635 bp += sizeof(int32_t); \
636 printf(" %d.%d", epoch, counter); \
639 #define AFSUUIDOUT() {u_int32_t temp; int i; \
640 TRUNC(11*sizeof(u_int32_t)); \
641 temp = ntohl(*((int *) bp)); \
642 bp += sizeof(u_int32_t); \
643 printf(" %08x", temp); \
644 temp = ntohl(*((int *) bp)); \
645 bp += sizeof(u_int32_t); \
646 printf("%04x", temp); \
647 temp = ntohl(*((int *) bp)); \
648 bp += sizeof(u_int32_t); \
649 printf("%04x", temp); \
650 for (i = 0; i < 8; i++) { \
651 temp = ntohl(*((int *) bp)); \
652 bp += sizeof(u_int32_t); \
653 printf("%02x", (unsigned char) temp); \
658 * This is the sickest one of all
661 #define VECOUT(MAX) { char *sp; \
663 TRUNC(MAX * sizeof(int32_t)); \
665 for (k = 0; k < MAX; k++) { \
666 *sp++ = (char) ntohl(*((int *) bp)); \
667 bp += sizeof(int32_t); \
670 printf(" \"%s\"", s); \
674 * Handle calls to the AFS file service (fs)
678 fs_print(register const u_char
*bp
, int length
)
684 if (length
<= sizeof(struct rx_header
))
687 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
692 * Print out the afs call we're invoking. The table used here was
693 * gleaned from fsint/afsint.xg
696 fs_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
698 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
701 * Print out arguments to some of the AFS calls. This stuff is
705 bp
+= sizeof(struct rx_header
) + 4;
708 * Sigh. This is gross. Ritchie forgive me.
712 case 130: /* Fetch data */
719 case 131: /* Fetch ACL */
720 case 132: /* Fetch Status */
721 case 143: /* Old set lock */
722 case 144: /* Old extend lock */
723 case 145: /* Old release lock */
724 case 156: /* Set lock */
725 case 157: /* Extend lock */
726 case 158: /* Release lock */
729 case 135: /* Store status */
733 case 133: /* Store data */
743 case 134: /* Store ACL */
745 char a
[AFSOPAQUEMAX
];
748 i
= ntohl(*((int *) bp
));
749 bp
+= sizeof(int32_t);
751 strncpy(a
, bp
, min(AFSOPAQUEMAX
, i
));
753 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
756 case 137: /* Create file */
757 case 141: /* MakeDir */
762 case 136: /* Remove file */
763 case 142: /* Remove directory */
767 case 138: /* Rename file */
775 case 139: /* Symlink */
787 case 148: /* Get volume info */
790 case 149: /* Get volume stats */
791 case 150: /* Set volume stats */
795 case 154: /* New get volume info */
799 case 155: /* Bulk stat */
803 j
= ntohl(*((int *) bp
));
804 bp
+= sizeof(int32_t);
806 for (i
= 0; i
< j
; i
++) {
825 * Handle replies to the AFS file service
829 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
833 struct rx_header
*rxh
;
835 if (length
<= sizeof(struct rx_header
))
838 rxh
= (struct rx_header
*) bp
;
841 * Print out the afs call we're invoking. The table used here was
842 * gleaned from fsint/afsint.xg
845 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
847 bp
+= sizeof(struct rx_header
);
850 * If it was a data packet, interpret the response
853 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
855 case 131: /* Fetch ACL */
857 char a
[AFSOPAQUEMAX
];
859 i
= ntohl(*((int *) bp
));
860 bp
+= sizeof(int32_t);
862 strncpy(a
, bp
, min(AFSOPAQUEMAX
, i
));
864 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
867 case 137: /* Create file */
868 case 141: /* MakeDir */
872 case 151: /* Get root volume */
873 printf(" root volume");
876 case 153: /* Get time */
884 * Otherwise, just print out the return code
897 * Print out an AFS ACL string. An AFS ACL is a string that has the
900 * <positive> <negative>
904 * "positive" and "negative" are integers which contain the number of
905 * positive and negative ACL's in the string. The uid/aclbits pair are
906 * ASCII strings containing the UID/PTS record and and a ascii number
907 * representing a logical OR of all the ACL permission bits
911 acl_print(u_char
*s
, u_char
*end
)
917 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
926 * This wacky order preserves the order used by the "fs" command
929 #define ACLOUT(acl) \
930 if (acl & PRSFS_READ) \
932 if (acl & PRSFS_LOOKUP) \
934 if (acl & PRSFS_INSERT) \
936 if (acl & PRSFS_DELETE) \
938 if (acl & PRSFS_WRITE) \
940 if (acl & PRSFS_LOCK) \
942 if (acl & PRSFS_ADMINISTER) \
945 for (i
= 0; i
< pos
; i
++) {
946 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
949 printf(" +{%s ", user
);
956 for (i
= 0; i
< neg
; i
++) {
957 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
960 printf(" -{%s ", user
);
971 * Handle calls to the AFS callback service
975 cb_print(register const u_char
*bp
, int length
)
980 if (length
<= sizeof(struct rx_header
))
983 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
988 * Print out the afs call we're invoking. The table used here was
989 * gleaned from fsint/afscbint.xg
992 cb_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
994 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
996 bp
+= sizeof(struct rx_header
) + 4;
999 * Print out the afs call we're invoking. The table used here was
1000 * gleaned from fsint/afscbint.xg
1004 case 204: /* Callback */
1008 j
= ntohl(*((int *) bp
));
1009 bp
+= sizeof(int32_t);
1011 for (i
= 0; i
< j
; i
++) {
1020 j
= ntohl(*((int *) bp
));
1021 bp
+= sizeof(int32_t);
1026 for (i
= 0; i
< j
; i
++) {
1032 t
= ntohl(*((int *) bp
));
1033 bp
+= sizeof(int32_t);
1034 tok2str(cb_types
, "type %d", t
);
1053 * Handle replies to the AFS Callback Service
1057 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1059 struct rx_header
*rxh
;
1061 if (length
<= sizeof(struct rx_header
))
1064 rxh
= (struct rx_header
*) bp
;
1067 * Print out the afs call we're invoking. The table used here was
1068 * gleaned from fsint/afscbint.xg
1071 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1073 bp
+= sizeof(struct rx_header
);
1076 * If it was a data packet, interpret the response.
1079 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1081 case 213: /* InitCallBackState3 */
1089 * Otherwise, just print out the return code
1102 * Handle calls to the AFS protection database server
1106 prot_print(register const u_char
*bp
, int length
)
1112 if (length
<= sizeof(struct rx_header
))
1115 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1120 * Print out the afs call we're invoking. The table used here was
1121 * gleaned from ptserver/ptint.xg
1124 pt_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1128 if (is_ubik(pt_op
)) {
1129 ubik_print(bp
, length
);
1133 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1136 * Decode some of the arguments to the PT calls
1139 bp
+= sizeof(struct rx_header
) + 4;
1142 case 500: /* I New User */
1149 case 501: /* Where is it */
1150 case 506: /* Delete */
1151 case 508: /* Get CPS */
1152 case 512: /* List entry */
1153 case 514: /* List elements */
1154 case 517: /* List owned */
1155 case 518: /* Get CPS2 */
1156 case 519: /* Get host CPS */
1160 case 502: /* Dump entry */
1164 case 503: /* Add to group */
1165 case 507: /* Remove from group */
1166 case 515: /* Is a member of? */
1172 case 504: /* Name to ID */
1176 j
= ntohl(*((int *) bp
));
1177 bp
+= sizeof(int32_t);
1180 * Who designed this chicken-shit protocol?
1182 * Each character is stored as a 32-bit
1186 for (i
= 0; i
< j
; i
++) {
1193 case 505: /* Id to name */
1198 i
= ntohl(*((int *) bp
));
1199 bp
+= sizeof(int32_t);
1200 for (j
= 0; j
< i
; j
++)
1206 case 509: /* New entry */
1213 case 511: /* Set max */
1219 case 513: /* Change entry */
1228 case 520: /* Update entry */
1245 * Handle replies to the AFS protection service
1249 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1251 struct rx_header
*rxh
;
1255 if (length
< sizeof(struct rx_header
))
1258 rxh
= (struct rx_header
*) bp
;
1261 * Print out the afs call we're invoking. The table used here was
1262 * gleaned from ptserver/ptint.xg. Check to see if it's a
1263 * Ubik call, however.
1268 if (is_ubik(opcode
)) {
1269 ubik_reply_print(bp
, length
, opcode
);
1273 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1275 bp
+= sizeof(struct rx_header
);
1278 * If it was a data packet, interpret the response
1281 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1283 case 504: /* Name to ID */
1288 i
= ntohl(*((int *) bp
));
1289 bp
+= sizeof(int32_t);
1290 for (j
= 0; j
< i
; j
++)
1296 case 505: /* ID to name */
1300 j
= ntohl(*((int *) bp
));
1301 bp
+= sizeof(int32_t);
1304 * Who designed this chicken-shit protocol?
1306 * Each character is stored as a 32-bit
1310 for (i
= 0; i
< j
; i
++) {
1317 case 508: /* Get CPS */
1318 case 514: /* List elements */
1319 case 517: /* List owned */
1320 case 518: /* Get CPS2 */
1321 case 519: /* Get host CPS */
1325 j
= ntohl(*((int *) bp
));
1326 bp
+= sizeof(int32_t);
1327 for (i
= 0; i
< j
; i
++) {
1334 case 510: /* List max */
1345 * Otherwise, just print out the return code
1358 * Handle calls to the AFS volume location database service
1362 vldb_print(register const u_char
*bp
, int length
)
1368 if (length
<= sizeof(struct rx_header
))
1371 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1376 * Print out the afs call we're invoking. The table used here was
1377 * gleaned from vlserver/vldbint.xg
1380 vldb_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1384 if (is_ubik(vldb_op
)) {
1385 ubik_print(bp
, length
);
1388 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1391 * Decode some of the arguments to the VLDB calls
1394 bp
+= sizeof(struct rx_header
) + 4;
1397 case 501: /* Create new volume */
1398 case 517: /* Create entry N */
1401 case 502: /* Delete entry */
1402 case 503: /* Get entry by ID */
1403 case 507: /* Update entry */
1404 case 508: /* Set lock */
1405 case 509: /* Release lock */
1406 case 518: /* Get entry by ID N */
1409 TRUNC(sizeof(int32_t));
1410 i
= ntohl(*((int *) bp
));
1411 bp
+= sizeof(int32_t);
1413 printf(" type %s", voltype
[i
]);
1415 case 504: /* Get entry by name */
1416 case 519: /* Get entry by name N */
1417 case 524: /* Update entry by name */
1418 case 527: /* Get entry by name U */
1421 case 505: /* Get new vol id */
1425 case 506: /* Replace entry */
1426 case 520: /* Replace entry N */
1429 TRUNC(sizeof(int32_t));
1430 i
= ntohl(*((int *) bp
));
1431 bp
+= sizeof(int32_t);
1433 printf(" type %s", voltype
[i
]);
1436 case 510: /* List entry */
1437 case 521: /* List entry N */
1452 * Handle replies to the AFS volume location database service
1456 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1458 struct rx_header
*rxh
;
1462 if (length
< sizeof(struct rx_header
))
1465 rxh
= (struct rx_header
*) bp
;
1468 * Print out the afs call we're invoking. The table used here was
1469 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1470 * Ubik call, however.
1475 if (is_ubik(opcode
)) {
1476 ubik_reply_print(bp
, length
, opcode
);
1480 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1482 bp
+= sizeof(struct rx_header
);
1485 * If it was a data packet, interpret the response
1488 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1490 case 510: /* List entry */
1493 printf(" nextindex");
1495 case 503: /* Get entry by id */
1496 case 504: /* Get entry by name */
1497 { unsigned long nservers
, j
;
1499 TRUNC(sizeof(int32_t));
1500 bp
+= sizeof(int32_t);
1501 printf(" numservers");
1502 TRUNC(sizeof(int32_t));
1503 nservers
= ntohl(*((int *) bp
));
1504 bp
+= sizeof(int32_t);
1505 printf(" %lu", nservers
);
1507 for (i
= 0; i
< 8; i
++) {
1508 TRUNC(sizeof(int32_t));
1511 inet_ntoa(*((struct in_addr
*) bp
)));
1512 bp
+= sizeof(int32_t);
1514 printf(" partitions");
1515 for (i
= 0; i
< 8; i
++) {
1516 TRUNC(sizeof(int32_t));
1517 j
= ntohl(*((int *) bp
));
1518 if (i
< nservers
&& j
<= 26)
1519 printf(" %c", 'a' + (int)j
);
1520 else if (i
< nservers
)
1522 bp
+= sizeof(int32_t);
1524 TRUNC(8 * sizeof(int32_t));
1525 bp
+= 8 * sizeof(int32_t);
1534 case 505: /* Get new volume ID */
1538 case 521: /* List entry */
1539 case 529: /* List entry U */
1542 printf(" nextindex");
1544 case 518: /* Get entry by ID N */
1545 case 519: /* Get entry by name N */
1546 { unsigned long nservers
, j
;
1548 printf(" numservers");
1549 TRUNC(sizeof(int32_t));
1550 nservers
= ntohl(*((int *) bp
));
1551 bp
+= sizeof(int32_t);
1552 printf(" %lu", nservers
);
1554 for (i
= 0; i
< 13; i
++) {
1555 TRUNC(sizeof(int32_t));
1558 inet_ntoa(*((struct in_addr
*) bp
)));
1559 bp
+= sizeof(int32_t);
1561 printf(" partitions");
1562 for (i
= 0; i
< 13; i
++) {
1563 TRUNC(sizeof(int32_t));
1564 j
= ntohl(*((int *) bp
));
1565 if (i
< nservers
&& j
<= 26)
1566 printf(" %c", 'a' + (int)j
);
1567 else if (i
< nservers
)
1569 bp
+= sizeof(int32_t);
1571 TRUNC(13 * sizeof(int32_t));
1572 bp
+= 13 * sizeof(int32_t);
1581 case 526: /* Get entry by ID U */
1582 case 527: /* Get entry by name U */
1583 { unsigned long nservers
, j
;
1585 printf(" numservers");
1586 TRUNC(sizeof(int32_t));
1587 nservers
= ntohl(*((int *) bp
));
1588 bp
+= sizeof(int32_t);
1589 printf(" %lu", nservers
);
1591 for (i
= 0; i
< 13; i
++) {
1602 printf(" partitions");
1603 for (i
= 0; i
< 13; i
++) {
1604 TRUNC(sizeof(int32_t));
1605 j
= ntohl(*((int *) bp
));
1606 if (i
< nservers
&& j
<= 26)
1607 printf(" %c", 'a' + (int)j
);
1608 else if (i
< nservers
)
1610 bp
+= sizeof(int32_t);
1612 TRUNC(13 * sizeof(int32_t));
1613 bp
+= 13 * sizeof(int32_t);
1627 * Otherwise, just print out the return code
1640 * Handle calls to the AFS Kerberos Authentication service
1644 kauth_print(register const u_char
*bp
, int length
)
1649 if (length
<= sizeof(struct rx_header
))
1652 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1657 * Print out the afs call we're invoking. The table used here was
1658 * gleaned from kauth/kauth.rg
1661 kauth_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1665 if (is_ubik(kauth_op
)) {
1666 ubik_print(bp
, length
);
1671 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1674 * Decode some of the arguments to the KA calls
1677 bp
+= sizeof(struct rx_header
) + 4;
1680 case 1: /* Authenticate old */;
1681 case 21: /* Authenticate */
1682 case 22: /* Authenticate-V2 */
1683 case 2: /* Change PW */
1684 case 5: /* Set fields */
1685 case 6: /* Create user */
1686 case 7: /* Delete user */
1687 case 8: /* Get entry */
1688 case 14: /* Unlock */
1689 case 15: /* Lock status */
1690 printf(" principal");
1694 case 3: /* GetTicket-old */
1695 case 23: /* GetTicket */
1702 TRUNC(sizeof(int32_t));
1703 i
= (int) ntohl(*((int *) bp
));
1704 bp
+= sizeof(int32_t);
1707 printf(" principal");
1712 case 4: /* Set Password */
1713 printf(" principal");
1719 case 12: /* Get password */
1730 printf(" [|kauth]");
1734 * Handle replies to the AFS Kerberos Authentication Service
1738 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1740 struct rx_header
*rxh
;
1742 if (length
<= sizeof(struct rx_header
))
1745 rxh
= (struct rx_header
*) bp
;
1748 * Print out the afs call we're invoking. The table used here was
1749 * gleaned from kauth/kauth.rg
1754 if (is_ubik(opcode
)) {
1755 ubik_reply_print(bp
, length
, opcode
);
1759 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1761 bp
+= sizeof(struct rx_header
);
1764 * If it was a data packet, interpret the response.
1767 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1768 /* Well, no, not really. Leave this for later */
1772 * Otherwise, just print out the return code
1781 printf(" [|kauth]");
1785 * Handle calls to the AFS Volume location service
1789 vol_print(register const u_char
*bp
, int length
)
1793 if (length
<= sizeof(struct rx_header
))
1796 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1801 * Print out the afs call we're invoking. The table used here was
1802 * gleaned from volser/volint.xg
1805 vol_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1807 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1810 * Normally there would be a switch statement here to decode the
1811 * arguments to the AFS call, but since I don't have access to
1812 * an AFS server (yet) and I'm not an AFS admin, I can't
1813 * test any of these calls. Leave this blank for now.
1823 * Handle replies to the AFS Volume Service
1827 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1829 struct rx_header
*rxh
;
1831 if (length
<= sizeof(struct rx_header
))
1834 rxh
= (struct rx_header
*) bp
;
1837 * Print out the afs call we're invoking. The table used here was
1838 * gleaned from volser/volint.xg
1841 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
1843 bp
+= sizeof(struct rx_header
);
1846 * If it was a data packet, interpret the response.
1849 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1850 /* Well, no, not really. Leave this for later */
1854 * Otherwise, just print out the return code
1867 * Handle calls to the AFS BOS service
1871 bos_print(register const u_char
*bp
, int length
)
1876 if (length
<= sizeof(struct rx_header
))
1879 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1884 * Print out the afs call we're invoking. The table used here was
1885 * gleaned from bozo/bosint.xg
1888 bos_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
1890 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
1893 * Decode some of the arguments to the BOS calls
1896 bp
+= sizeof(struct rx_header
) + 4;
1899 case 80: /* Create B node */
1902 printf(" instance");
1905 case 81: /* Delete B node */
1906 case 83: /* Get status */
1907 case 85: /* Get instance info */
1908 case 87: /* Add super user */
1909 case 88: /* Delete super user */
1910 case 93: /* Set cell name */
1911 case 96: /* Add cell host */
1912 case 97: /* Delete cell host */
1913 case 104: /* Restart */
1914 case 106: /* Uninstall */
1915 case 108: /* Exec */
1916 case 112: /* Getlog */
1917 case 114: /* Get instance strings */
1920 case 82: /* Set status */
1921 case 98: /* Set T status */
1926 case 86: /* Get instance parm */
1931 case 84: /* Enumerate instance */
1932 case 89: /* List super users */
1933 case 90: /* List keys */
1934 case 91: /* Add key */
1935 case 92: /* Delete key */
1936 case 95: /* Get cell host */
1939 case 105: /* Install */
1959 * Handle replies to the AFS BOS Service
1963 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1965 struct rx_header
*rxh
;
1967 if (length
<= sizeof(struct rx_header
))
1970 rxh
= (struct rx_header
*) bp
;
1973 * Print out the afs call we're invoking. The table used here was
1974 * gleaned from volser/volint.xg
1977 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
1979 bp
+= sizeof(struct rx_header
);
1982 * If it was a data packet, interpret the response.
1985 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1986 /* Well, no, not really. Leave this for later */
1990 * Otherwise, just print out the return code
2003 * Check to see if this is a Ubik opcode.
2007 is_ubik(u_int32_t opcode
)
2009 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2010 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2017 * Handle Ubik opcodes to any one of the replicated database services
2021 ubik_print(register const u_char
*bp
, int length
)
2027 * Print out the afs call we're invoking. The table used here was
2028 * gleaned from ubik/ubik_int.xg
2031 ubik_op
= ntohl(*((int *) (bp
+ sizeof(struct rx_header
))));
2033 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2036 * Decode some of the arguments to the Ubik calls
2039 bp
+= sizeof(struct rx_header
) + 4;
2042 case 10000: /* Beacon */
2044 temp
= ntohl(*((int *) bp
));
2045 bp
+= sizeof(int32_t);
2046 printf(" syncsite %s", temp
? "yes" : "no");
2047 printf(" votestart");
2049 printf(" dbversion");
2054 case 10003: /* Get sync site */
2058 case 20000: /* Begin */
2059 case 20001: /* Commit */
2060 case 20007: /* Abort */
2061 case 20008: /* Release locks */
2062 case 20010: /* Writev */
2066 case 20002: /* Lock */
2075 temp
= ntohl(*((int *) bp
));
2076 bp
+= sizeof(int32_t);
2077 tok2str(ubik_lock_types
, "type %d", temp
);
2079 case 20003: /* Write */
2087 case 20005: /* Get file */
2091 case 20006: /* Send file */
2096 printf(" dbversion");
2099 case 20009: /* Truncate */
2107 case 20012: /* Set version */
2110 printf(" oldversion");
2112 printf(" newversion");
2126 * Handle Ubik replies to any one of the replicated database services
2130 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2132 struct rx_header
*rxh
;
2134 if (length
< sizeof(struct rx_header
))
2137 rxh
= (struct rx_header
*) bp
;
2140 * Print out the ubik call we're invoking. This table was gleaned
2141 * from ubik/ubik_int.xg
2144 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2146 bp
+= sizeof(struct rx_header
);
2149 * If it was a data packet, print out the arguments to the Ubik calls
2152 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2154 case 10000: /* Beacon */
2157 case 20004: /* Get version */
2158 printf(" dbversion");
2166 * Otherwise, print out "yes" it it was a beacon packet (because
2167 * that's how yes votes are returned, go figure), otherwise
2168 * just print out the error code.
2173 case 10000: /* Beacon */
2174 printf(" vote yes until");