]>
The Tcpdump Group git mirrors - tcpdump/blob - print-rx.c
2 * Copyright: (c) 2000 United States Government as represented by the
3 * Secretary of the Navy. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
15 * 3. The names of the authors may not be used to endorse or promote
16 * products derived from this software without specific prior
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 * This code unmangles RX packets. RX is the mutant form of RPC that AFS
25 * uses to communicate between clients and servers.
27 * In this code, I mainly concern myself with decoding the AFS calls, not
28 * with the guts of RX, per se.
30 * Bah. If I never look at rx_packet.h again, it will be too soon.
32 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
36 static const char rcsid
[] _U_
=
37 "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.42 2008-07-01 07:44:50 guy Exp $";
47 #include <tcpdump-stdinc.h>
49 #include "interface.h"
50 #include "addrtoname.h"
55 #define FS_RX_PORT 7000
56 #define CB_RX_PORT 7001
57 #define PROT_RX_PORT 7002
58 #define VLDB_RX_PORT 7003
59 #define KAUTH_RX_PORT 7004
60 #define VOL_RX_PORT 7005
61 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
62 #define BOS_RX_PORT 7007
64 #define AFSNAMEMAX 256
65 #define AFSOPAQUEMAX 1024
69 #define BOSNAMEMAX 256
71 #define PRSFS_READ 1 /* Read files */
72 #define PRSFS_WRITE 2 /* Write files */
73 #define PRSFS_INSERT 4 /* Insert files into a directory */
74 #define PRSFS_LOOKUP 8 /* Lookup files into a directory */
75 #define PRSFS_DELETE 16 /* Delete files */
76 #define PRSFS_LOCK 32 /* Lock files */
77 #define PRSFS_ADMINISTER 64 /* Change ACL's */
86 #define RX_PACKET_TYPE_DATA 1
87 #define RX_PACKET_TYPE_ACK 2
88 #define RX_PACKET_TYPE_BUSY 3
89 #define RX_PACKET_TYPE_ABORT 4
90 #define RX_PACKET_TYPE_ACKALL 5
91 #define RX_PACKET_TYPE_CHALLENGE 6
92 #define RX_PACKET_TYPE_RESPONSE 7
93 #define RX_PACKET_TYPE_DEBUG 8
94 #define RX_PACKET_TYPE_PARAMS 9
95 #define RX_PACKET_TYPE_VERSION 13
97 #define RX_CLIENT_INITIATED 1
98 #define RX_REQUEST_ACK 2
99 #define RX_LAST_PACKET 4
100 #define RX_MORE_PACKETS 8
101 #define RX_FREE_PACKET 16
102 #define RX_SLOW_START_OK 32
103 #define RX_JUMBO_PACKET 32
105 u_int8_t securityIndex
;
106 u_int16_t spare
; /* How clever: even though the AFS */
107 u_int16_t serviceId
; /* header files indicate that the */
108 }; /* serviceId is first, it's really */
109 /* encoded _after_ the spare field */
110 /* I wasted a day figuring that out! */
112 #define NUM_RX_FLAGS 7
114 #define RX_MAXACKS 255
116 struct rx_ackPacket
{
117 u_int16_t bufferSpace
; /* Number of packet buffers available */
118 u_int16_t maxSkew
; /* Max diff between ack'd packet and */
119 /* highest packet received */
120 u_int32_t firstPacket
; /* The first packet in ack list */
121 u_int32_t previousPacket
; /* Previous packet recv'd (obsolete) */
122 u_int32_t serial
; /* # of packet that prompted the ack */
123 u_int8_t reason
; /* Reason for acknowledgement */
124 u_int8_t nAcks
; /* Number of acknowledgements */
125 u_int8_t acks
[RX_MAXACKS
]; /* Up to RX_MAXACKS acknowledgements */
129 * Values for the acks array
132 #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
133 #define RX_ACK_TYPE_ACK 1 /* I have this packet */
135 static const struct tok rx_types
[] = {
136 { RX_PACKET_TYPE_DATA
, "data" },
137 { RX_PACKET_TYPE_ACK
, "ack" },
138 { RX_PACKET_TYPE_BUSY
, "busy" },
139 { RX_PACKET_TYPE_ABORT
, "abort" },
140 { RX_PACKET_TYPE_ACKALL
, "ackall" },
141 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
142 { RX_PACKET_TYPE_RESPONSE
, "response" },
143 { RX_PACKET_TYPE_DEBUG
, "debug" },
144 { RX_PACKET_TYPE_PARAMS
, "params" },
145 { RX_PACKET_TYPE_VERSION
, "version" },
149 static const struct double_tok
{
150 int flag
; /* Rx flag */
151 int packetType
; /* Packet type */
152 const char *s
; /* Flag string */
154 { RX_CLIENT_INITIATED
, 0, "client-init" },
155 { RX_REQUEST_ACK
, 0, "req-ack" },
156 { RX_LAST_PACKET
, 0, "last-pckt" },
157 { RX_MORE_PACKETS
, 0, "more-pckts" },
158 { RX_FREE_PACKET
, 0, "free-pckt" },
159 { RX_SLOW_START_OK
, RX_PACKET_TYPE_ACK
, "slow-start" },
160 { RX_JUMBO_PACKET
, RX_PACKET_TYPE_DATA
, "jumbogram" }
163 static const struct tok fs_req
[] = {
164 { 130, "fetch-data" },
165 { 131, "fetch-acl" },
166 { 132, "fetch-status" },
167 { 133, "store-data" },
168 { 134, "store-acl" },
169 { 135, "store-status" },
170 { 136, "remove-file" },
171 { 137, "create-file" },
177 { 143, "oldsetlock" },
178 { 144, "oldextlock" },
179 { 145, "oldrellock" },
180 { 146, "get-stats" },
182 { 148, "get-vlinfo" },
183 { 149, "get-vlstats" },
184 { 150, "set-vlstats" },
185 { 151, "get-rootvl" },
186 { 152, "check-token" },
188 { 154, "nget-vlinfo" },
189 { 155, "bulk-stat" },
193 { 159, "xstat-ver" },
194 { 160, "get-xstat" },
195 { 161, "dfs-lookup" },
196 { 162, "dfs-flushcps" },
197 { 163, "dfs-symlink" },
198 { 220, "residency" },
199 { 65536, "inline-bulk-status" },
200 { 65537, "fetch-data-64" },
201 { 65538, "store-data-64" },
202 { 65539, "give-up-all-cbs" },
203 { 65540, "get-caps" },
204 { 65541, "cb-rx-conn-addr" },
208 static const struct tok cb_req
[] = {
217 { 212, "whoareyou" },
219 { 214, "probeuuid" },
220 { 215, "getsrvprefs" },
221 { 216, "getcellservdb" },
222 { 217, "getlocalcell" },
223 { 218, "getcacheconf" },
224 { 65536, "getce64" },
225 { 65537, "getcellbynum" },
226 { 65538, "tellmeaboutyourself" },
230 static const struct tok pt_req
[] = {
232 { 501, "where-is-it" },
233 { 502, "dump-entry" },
234 { 503, "add-to-group" },
235 { 504, "name-to-id" },
236 { 505, "id-to-name" },
238 { 507, "remove-from-group" },
240 { 509, "new-entry" },
243 { 512, "list-entry" },
244 { 513, "change-entry" },
245 { 514, "list-elements" },
246 { 515, "same-mbr-of" },
247 { 516, "set-fld-sentry" },
248 { 517, "list-owned" },
250 { 519, "get-host-cps" },
251 { 520, "update-entry" },
252 { 521, "list-entries" },
253 { 530, "list-super-groups" },
257 static const struct tok vldb_req
[] = {
258 { 501, "create-entry" },
259 { 502, "delete-entry" },
260 { 503, "get-entry-by-id" },
261 { 504, "get-entry-by-name" },
262 { 505, "get-new-volume-id" },
263 { 506, "replace-entry" },
264 { 507, "update-entry" },
266 { 509, "releaselock" },
267 { 510, "list-entry" },
268 { 511, "list-attrib" },
269 { 512, "linked-list" },
270 { 513, "get-stats" },
272 { 515, "get-addrs" },
273 { 516, "change-addr" },
274 { 517, "create-entry-n" },
275 { 518, "get-entry-by-id-n" },
276 { 519, "get-entry-by-name-n" },
277 { 520, "replace-entry-n" },
278 { 521, "list-entry-n" },
279 { 522, "list-attrib-n" },
280 { 523, "linked-list-n" },
281 { 524, "update-entry-by-name" },
282 { 525, "create-entry-u" },
283 { 526, "get-entry-by-id-u" },
284 { 527, "get-entry-by-name-u" },
285 { 528, "replace-entry-u" },
286 { 529, "list-entry-u" },
287 { 530, "list-attrib-u" },
288 { 531, "linked-list-u" },
290 { 533, "get-addrs-u" },
291 { 534, "list-attrib-n2" },
295 static const struct tok kauth_req
[] = {
297 { 21, "authenticate" },
298 { 22, "authenticate-v2" },
300 { 3, "get-ticket-old" },
301 { 23, "get-ticket" },
304 { 6, "create-user" },
305 { 7, "delete-user" },
311 { 13, "get-random-key" },
313 { 15, "lock-status" },
317 static const struct tok vol_req
[] = {
318 { 100, "create-volume" },
319 { 101, "delete-volume" },
322 { 104, "end-trans" },
324 { 106, "set-flags" },
325 { 107, "get-flags" },
326 { 108, "trans-create" },
328 { 110, "get-nth-volume" },
329 { 111, "set-forwarding" },
331 { 113, "get-status" },
332 { 114, "sig-restore" },
333 { 115, "list-partitions" },
334 { 116, "list-volumes" },
335 { 117, "set-id-types" },
337 { 119, "partition-info" },
339 { 121, "list-one-volume" },
342 { 124, "x-list-volumes" },
343 { 125, "x-list-one-volume" },
345 { 127, "x-list-partitions" },
346 { 128, "forward-multiple" },
347 { 65536, "convert-ro" },
348 { 65537, "get-size" },
349 { 65538, "dump-v2" },
353 static const struct tok bos_req
[] = {
354 { 80, "create-bnode" },
355 { 81, "delete-bnode" },
356 { 82, "set-status" },
357 { 83, "get-status" },
358 { 84, "enumerate-instance" },
359 { 85, "get-instance-info" },
360 { 86, "get-instance-parm" },
361 { 87, "add-superuser" },
362 { 88, "delete-superuser" },
363 { 89, "list-superusers" },
366 { 92, "delete-key" },
367 { 93, "set-cell-name" },
368 { 94, "get-cell-name" },
369 { 95, "get-cell-host" },
370 { 96, "add-cell-host" },
371 { 97, "delete-cell-host" },
372 { 98, "set-t-status" },
373 { 99, "shutdown-all" },
374 { 100, "restart-all" },
375 { 101, "startup-all" },
376 { 102, "set-noauth-flag" },
379 { 105, "start-bozo-install" },
380 { 106, "uninstall" },
381 { 107, "get-dates" },
384 { 110, "set-restart-time" },
385 { 111, "get-restart-time" },
386 { 112, "start-bozo-log" },
388 { 114, "get-instance-strings" },
389 { 115, "get-restricted" },
390 { 116, "set-restricted" },
394 static const struct tok ubik_req
[] = {
395 { 10000, "vote-beacon" },
396 { 10001, "vote-debug-old" },
397 { 10002, "vote-sdebug-old" },
398 { 10003, "vote-getsyncsite" },
399 { 10004, "vote-debug" },
400 { 10005, "vote-sdebug" },
401 { 10006, "vote-xdebug" },
402 { 10007, "vote-xsdebug" },
403 { 20000, "disk-begin" },
404 { 20001, "disk-commit" },
405 { 20002, "disk-lock" },
406 { 20003, "disk-write" },
407 { 20004, "disk-getversion" },
408 { 20005, "disk-getfile" },
409 { 20006, "disk-sendfile" },
410 { 20007, "disk-abort" },
411 { 20008, "disk-releaselocks" },
412 { 20009, "disk-truncate" },
413 { 20010, "disk-probe" },
414 { 20011, "disk-writev" },
415 { 20012, "disk-interfaceaddr" },
416 { 20013, "disk-setversion" },
420 #define VOTE_LOW 10000
421 #define VOTE_HIGH 10007
422 #define DISK_LOW 20000
423 #define DISK_HIGH 20013
425 static const struct tok cb_types
[] = {
432 static const struct tok ubik_lock_types
[] = {
439 static const char *voltype
[] = { "read-write", "read-only", "backup" };
441 static const struct tok afs_fs_errors
[] = {
442 { 101, "salvage volume" },
443 { 102, "no such vnode" },
444 { 103, "no such volume" },
445 { 104, "volume exist" },
446 { 105, "no service" },
447 { 106, "volume offline" },
448 { 107, "voline online" },
450 { 109, "diskquota exceeded" },
451 { 110, "volume busy" },
452 { 111, "volume moved" },
453 { 112, "AFS IO error" },
454 { -100, "restarting fileserver" },
459 * Reasons for acknowledging a packet
462 static const struct tok rx_ack_reasons
[] = {
463 { 1, "ack requested" },
464 { 2, "duplicate packet" },
465 { 3, "out of sequence" },
466 { 4, "exceeds window" },
467 { 5, "no buffer space" },
469 { 7, "ping response" },
476 * Cache entries we keep around so we can figure out the RX opcode
477 * numbers for replies. This allows us to make sense of RX reply packets.
480 struct rx_cache_entry
{
481 u_int32_t callnum
; /* Call number (net order) */
482 struct in_addr client
; /* client IP address (net order) */
483 struct in_addr server
; /* server IP address (net order) */
484 int dport
; /* server port (host order) */
485 u_short serviceId
; /* Service identifier (net order) */
486 u_int32_t opcode
; /* RX opcode (host order) */
489 #define RX_CACHE_SIZE 64
491 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
493 static int rx_cache_next
= 0;
494 static int rx_cache_hint
= 0;
495 static void rx_cache_insert(const u_char
*, const struct ip
*, int);
496 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
499 static void fs_print(const u_char
*, int);
500 static void fs_reply_print(const u_char
*, int, int32_t);
501 static void acl_print(u_char
*, int, u_char
*);
502 static void cb_print(const u_char
*, int);
503 static void cb_reply_print(const u_char
*, int, int32_t);
504 static void prot_print(const u_char
*, int);
505 static void prot_reply_print(const u_char
*, int, int32_t);
506 static void vldb_print(const u_char
*, int);
507 static void vldb_reply_print(const u_char
*, int, int32_t);
508 static void kauth_print(const u_char
*, int);
509 static void kauth_reply_print(const u_char
*, int, int32_t);
510 static void vol_print(const u_char
*, int);
511 static void vol_reply_print(const u_char
*, int, int32_t);
512 static void bos_print(const u_char
*, int);
513 static void bos_reply_print(const u_char
*, int, int32_t);
514 static void ubik_print(const u_char
*);
515 static void ubik_reply_print(const u_char
*, int, int32_t);
517 static void rx_ack_print(const u_char
*, int);
519 static int is_ubik(u_int32_t
);
522 * Handle the rx-level packet. See if we know what port it's going to so
523 * we can peek at the afs call inside
527 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
530 register struct rx_header
*rxh
;
534 if (snapend
- bp
< (int)sizeof (struct rx_header
)) {
535 printf(" [|rx] (%d)", length
);
539 rxh
= (struct rx_header
*) bp
;
541 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
547 printf(" cid %08x call# %d",
548 (int) EXTRACT_32BITS(&rxh
->cid
),
549 (int) EXTRACT_32BITS(&rxh
->callNumber
));
551 printf(" seq %d ser %d",
552 (int) EXTRACT_32BITS(&rxh
->seq
),
553 (int) EXTRACT_32BITS(&rxh
->serial
));
556 printf(" secindex %d serviceid %hu",
557 (int) rxh
->securityIndex
,
558 EXTRACT_16BITS(&rxh
->serviceId
));
561 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
562 if (rxh
->flags
& rx_flags
[i
].flag
&&
563 (!rx_flags
[i
].packetType
||
564 rxh
->type
== rx_flags
[i
].packetType
)) {
571 printf("<%s>", rx_flags
[i
].s
);
577 * Try to handle AFS calls that we know about. Check the destination
578 * port and make sure it's a data packet. Also, make sure the
579 * seq number is 1 (because otherwise it's a continuation packet,
580 * and we can't interpret that). Also, seems that reply packets
581 * do not have the client-init flag set, so we check for that
585 if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
586 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
587 rxh
->flags
& RX_CLIENT_INITIATED
) {
590 * Insert this call into the call cache table, so we
591 * have a chance to print out replies
594 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
);
597 case FS_RX_PORT
: /* AFS file service */
598 fs_print(bp
, length
);
600 case CB_RX_PORT
: /* AFS callback service */
601 cb_print(bp
, length
);
603 case PROT_RX_PORT
: /* AFS protection service */
604 prot_print(bp
, length
);
606 case VLDB_RX_PORT
: /* AFS VLDB service */
607 vldb_print(bp
, length
);
609 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
610 kauth_print(bp
, length
);
612 case VOL_RX_PORT
: /* AFS Volume service */
613 vol_print(bp
, length
);
615 case BOS_RX_PORT
: /* AFS BOS service */
616 bos_print(bp
, length
);
623 * If it's a reply (client-init is _not_ set, but seq is one)
624 * then look it up in the cache. If we find it, call the reply
625 * printing functions Note that we handle abort packets here,
626 * because printing out the return code can be useful at times.
629 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
630 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
631 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
632 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
633 rx_cache_find(rxh
, (const struct ip
*) bp2
,
637 case FS_RX_PORT
: /* AFS file service */
638 fs_reply_print(bp
, length
, opcode
);
640 case CB_RX_PORT
: /* AFS callback service */
641 cb_reply_print(bp
, length
, opcode
);
643 case PROT_RX_PORT
: /* AFS PT service */
644 prot_reply_print(bp
, length
, opcode
);
646 case VLDB_RX_PORT
: /* AFS VLDB service */
647 vldb_reply_print(bp
, length
, opcode
);
649 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
650 kauth_reply_print(bp
, length
, opcode
);
652 case VOL_RX_PORT
: /* AFS Volume service */
653 vol_reply_print(bp
, length
, opcode
);
655 case BOS_RX_PORT
: /* AFS BOS service */
656 bos_reply_print(bp
, length
, opcode
);
663 * If it's an RX ack packet, then use the appropriate ack decoding
664 * function (there isn't any service-specific information in the
665 * ack packet, so we can use one for all AFS services)
668 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
669 rx_ack_print(bp
, length
);
672 printf(" (%d)", length
);
676 * Insert an entry into the cache. Taken from print-nfs.c
680 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
)
682 struct rx_cache_entry
*rxent
;
683 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
685 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t)))
688 rxent
= &rx_cache
[rx_cache_next
];
690 if (++rx_cache_next
>= RX_CACHE_SIZE
)
693 rxent
->callnum
= rxh
->callNumber
;
694 rxent
->client
= ip
->ip_src
;
695 rxent
->server
= ip
->ip_dst
;
696 rxent
->dport
= dport
;
697 rxent
->serviceId
= rxh
->serviceId
;
698 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
702 * Lookup an entry in the cache. Also taken from print-nfs.c
704 * Note that because this is a reply, we're looking at the _source_
709 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
713 struct rx_cache_entry
*rxent
;
714 u_int32_t clip
= ip
->ip_dst
.s_addr
;
715 u_int32_t sip
= ip
->ip_src
.s_addr
;
717 /* Start the search where we last left off */
721 rxent
= &rx_cache
[i
];
722 if (rxent
->callnum
== rxh
->callNumber
&&
723 rxent
->client
.s_addr
== clip
&&
724 rxent
->server
.s_addr
== sip
&&
725 rxent
->serviceId
== rxh
->serviceId
&&
726 rxent
->dport
== sport
) {
728 /* We got a match! */
731 *opcode
= rxent
->opcode
;
734 if (++i
>= RX_CACHE_SIZE
)
736 } while (i
!= rx_cache_hint
);
738 /* Our search failed */
743 * These extrememly grody macros handle the printing of various AFS stuff.
746 #define FIDOUT() { unsigned long n1, n2, n3; \
747 TCHECK2(bp[0], sizeof(int32_t) * 3); \
748 n1 = EXTRACT_32BITS(bp); \
749 bp += sizeof(int32_t); \
750 n2 = EXTRACT_32BITS(bp); \
751 bp += sizeof(int32_t); \
752 n3 = EXTRACT_32BITS(bp); \
753 bp += sizeof(int32_t); \
754 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
757 #define STROUT(MAX) { unsigned int i; \
758 TCHECK2(bp[0], sizeof(int32_t)); \
759 i = EXTRACT_32BITS(bp); \
762 bp += sizeof(int32_t); \
764 if (fn_printn(bp, i, snapend)) \
767 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
770 #define INTOUT() { int i; \
771 TCHECK2(bp[0], sizeof(int32_t)); \
772 i = (int) EXTRACT_32BITS(bp); \
773 bp += sizeof(int32_t); \
777 #define UINTOUT() { unsigned long i; \
778 TCHECK2(bp[0], sizeof(int32_t)); \
779 i = EXTRACT_32BITS(bp); \
780 bp += sizeof(int32_t); \
784 #define UINT64OUT() { u_int64_t i; \
785 TCHECK2(bp[0], sizeof(u_int64_t)); \
786 i = EXTRACT_64BITS(bp); \
787 bp += sizeof(u_int64_t); \
788 printf(" %" PRIu64, i); \
791 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
792 TCHECK2(bp[0], sizeof(int32_t)); \
793 t = (time_t) EXTRACT_32BITS(bp); \
794 bp += sizeof(int32_t); \
795 tm = localtime(&t); \
796 strftime(str, 256, "%Y/%m/%d %T", tm); \
797 printf(" %s", str); \
800 #define STOREATTROUT() { unsigned long mask, i; \
801 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
802 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
803 if (mask) printf (" StoreStatus"); \
804 if (mask & 1) { printf(" date"); DATEOUT(); } \
805 else bp += sizeof(int32_t); \
806 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
807 if (mask & 2) printf(" owner %lu", i); \
808 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
809 if (mask & 4) printf(" group %lu", i); \
810 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
811 if (mask & 8) printf(" mode %lo", i & 07777); \
812 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
813 if (mask & 16) printf(" segsize %lu", i); \
814 /* undocumented in 3.3 docu */ \
815 if (mask & 1024) printf(" fsync"); \
818 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
819 TCHECK2(bp[0], sizeof(int32_t) * 2); \
820 epoch = EXTRACT_32BITS(bp); \
821 bp += sizeof(int32_t); \
822 counter = EXTRACT_32BITS(bp); \
823 bp += sizeof(int32_t); \
824 printf(" %d.%d", epoch, counter); \
827 #define AFSUUIDOUT() {u_int32_t temp; int i; \
828 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
829 temp = EXTRACT_32BITS(bp); \
830 bp += sizeof(u_int32_t); \
831 printf(" %08x", temp); \
832 temp = EXTRACT_32BITS(bp); \
833 bp += sizeof(u_int32_t); \
834 printf("%04x", temp); \
835 temp = EXTRACT_32BITS(bp); \
836 bp += sizeof(u_int32_t); \
837 printf("%04x", temp); \
838 for (i = 0; i < 8; i++) { \
839 temp = EXTRACT_32BITS(bp); \
840 bp += sizeof(u_int32_t); \
841 printf("%02x", (unsigned char) temp); \
846 * This is the sickest one of all
849 #define VECOUT(MAX) { u_char *sp; \
850 u_char s[AFSNAMEMAX]; \
852 if ((MAX) + 1 > sizeof(s)) \
854 TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
856 for (k = 0; k < (MAX); k++) { \
857 *sp++ = (u_char) EXTRACT_32BITS(bp); \
858 bp += sizeof(int32_t); \
866 #define DESTSERVEROUT() { unsigned long n1, n2, n3; \
867 TCHECK2(bp[0], sizeof(int32_t) * 3); \
868 n1 = EXTRACT_32BITS(bp); \
869 bp += sizeof(int32_t); \
870 n2 = EXTRACT_32BITS(bp); \
871 bp += sizeof(int32_t); \
872 n3 = EXTRACT_32BITS(bp); \
873 bp += sizeof(int32_t); \
874 printf(" server %d:%d:%d", (int) n1, (int) n2, (int) n3); \
878 * Handle calls to the AFS file service (fs)
882 fs_print(register const u_char
*bp
, int length
)
887 if (length
<= (int)sizeof(struct rx_header
))
890 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
895 * Print out the afs call we're invoking. The table used here was
896 * gleaned from fsint/afsint.xg
899 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
901 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
904 * Print out arguments to some of the AFS calls. This stuff is
908 bp
+= sizeof(struct rx_header
) + 4;
911 * Sigh. This is gross. Ritchie forgive me.
915 case 130: /* Fetch data */
922 case 131: /* Fetch ACL */
923 case 132: /* Fetch Status */
924 case 143: /* Old set lock */
925 case 144: /* Old extend lock */
926 case 145: /* Old release lock */
927 case 156: /* Set lock */
928 case 157: /* Extend lock */
929 case 158: /* Release lock */
932 case 135: /* Store status */
936 case 133: /* Store data */
946 case 134: /* Store ACL */
948 char a
[AFSOPAQUEMAX
+1];
951 i
= EXTRACT_32BITS(bp
);
952 bp
+= sizeof(int32_t);
954 i
= min(AFSOPAQUEMAX
, i
);
955 strncpy(a
, (char *) bp
, i
);
957 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
960 case 137: /* Create file */
961 case 141: /* MakeDir */
966 case 136: /* Remove file */
967 case 142: /* Remove directory */
971 case 138: /* Rename file */
979 case 139: /* Symlink */
991 case 148: /* Get volume info */
994 case 149: /* Get volume stats */
995 case 150: /* Set volume stats */
999 case 154: /* New get volume info */
1003 case 155: /* Bulk stat */
1004 case 65536: /* Inline bulk stat */
1008 j
= EXTRACT_32BITS(bp
);
1009 bp
+= sizeof(int32_t);
1011 for (i
= 0; i
< j
; i
++) {
1019 case 65537: /* Fetch data 64 */
1026 case 65538: /* Store data 64 */
1036 case 65541: /* CallBack rx conn address */
1050 * Handle replies to the AFS file service
1054 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1057 struct rx_header
*rxh
;
1059 if (length
<= (int)sizeof(struct rx_header
))
1062 rxh
= (struct rx_header
*) bp
;
1065 * Print out the afs call we're invoking. The table used here was
1066 * gleaned from fsint/afsint.xg
1069 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
1071 bp
+= sizeof(struct rx_header
);
1074 * If it was a data packet, interpret the response
1077 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
1079 case 131: /* Fetch ACL */
1081 char a
[AFSOPAQUEMAX
+1];
1083 i
= EXTRACT_32BITS(bp
);
1084 bp
+= sizeof(int32_t);
1086 i
= min(AFSOPAQUEMAX
, i
);
1087 strncpy(a
, (char *) bp
, i
);
1089 acl_print((u_char
*) a
, sizeof(a
), (u_char
*) a
+ i
);
1092 case 137: /* Create file */
1093 case 141: /* MakeDir */
1097 case 151: /* Get root volume */
1098 printf(" root volume");
1101 case 153: /* Get time */
1107 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1111 * Otherwise, just print out the return code
1113 TCHECK2(bp
[0], sizeof(int32_t));
1114 i
= (int) EXTRACT_32BITS(bp
);
1115 bp
+= sizeof(int32_t);
1117 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1119 printf(" strange fs reply of type %d", rxh
->type
);
1129 * Print out an AFS ACL string. An AFS ACL is a string that has the
1132 * <positive> <negative>
1136 * "positive" and "negative" are integers which contain the number of
1137 * positive and negative ACL's in the string. The uid/aclbits pair are
1138 * ASCII strings containing the UID/PTS record and and a ascii number
1139 * representing a logical OR of all the ACL permission bits
1143 acl_print(u_char
*s
, int maxsize
, u_char
*end
)
1150 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1153 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1162 * This wacky order preserves the order used by the "fs" command
1165 #define ACLOUT(acl) \
1166 if (acl & PRSFS_READ) \
1168 if (acl & PRSFS_LOOKUP) \
1170 if (acl & PRSFS_INSERT) \
1172 if (acl & PRSFS_DELETE) \
1174 if (acl & PRSFS_WRITE) \
1176 if (acl & PRSFS_LOCK) \
1178 if (acl & PRSFS_ADMINISTER) \
1181 for (i
= 0; i
< pos
; i
++) {
1182 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1183 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1187 fn_print((u_char
*)user
, NULL
);
1195 for (i
= 0; i
< neg
; i
++) {
1196 snprintf(fmt
, sizeof(fmt
), "%%%ds %%d\n%%n", maxsize
- 1);
1197 if (sscanf((char *) s
, fmt
, user
, &acl
, &n
) != 2)
1201 fn_print((u_char
*)user
, NULL
);
1217 * Handle calls to the AFS callback service
1221 cb_print(register const u_char
*bp
, int length
)
1226 if (length
<= (int)sizeof(struct rx_header
))
1229 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1234 * Print out the afs call we're invoking. The table used here was
1235 * gleaned from fsint/afscbint.xg
1238 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1240 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1242 bp
+= sizeof(struct rx_header
) + 4;
1245 * Print out the afs call we're invoking. The table used here was
1246 * gleaned from fsint/afscbint.xg
1250 case 204: /* Callback */
1254 j
= EXTRACT_32BITS(bp
);
1255 bp
+= sizeof(int32_t);
1257 for (i
= 0; i
< j
; i
++) {
1266 j
= EXTRACT_32BITS(bp
);
1267 bp
+= sizeof(int32_t);
1272 for (i
= 0; i
< j
; i
++) {
1278 t
= EXTRACT_32BITS(bp
);
1279 bp
+= sizeof(int32_t);
1280 tok2str(cb_types
, "type %d", t
);
1299 * Handle replies to the AFS Callback Service
1303 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1305 struct rx_header
*rxh
;
1307 if (length
<= (int)sizeof(struct rx_header
))
1310 rxh
= (struct rx_header
*) bp
;
1313 * Print out the afs call we're invoking. The table used here was
1314 * gleaned from fsint/afscbint.xg
1317 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1319 bp
+= sizeof(struct rx_header
);
1322 * If it was a data packet, interpret the response.
1325 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1327 case 213: /* InitCallBackState3 */
1335 * Otherwise, just print out the return code
1348 * Handle calls to the AFS protection database server
1352 prot_print(register const u_char
*bp
, int length
)
1357 if (length
<= (int)sizeof(struct rx_header
))
1360 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1365 * Print out the afs call we're invoking. The table used here was
1366 * gleaned from ptserver/ptint.xg
1369 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1373 if (is_ubik(pt_op
)) {
1378 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1381 * Decode some of the arguments to the PT calls
1384 bp
+= sizeof(struct rx_header
) + 4;
1387 case 500: /* I New User */
1394 case 501: /* Where is it */
1395 case 506: /* Delete */
1396 case 508: /* Get CPS */
1397 case 512: /* List entry */
1398 case 514: /* List elements */
1399 case 517: /* List owned */
1400 case 518: /* Get CPS2 */
1401 case 519: /* Get host CPS */
1402 case 530: /* List super groups */
1406 case 502: /* Dump entry */
1410 case 503: /* Add to group */
1411 case 507: /* Remove from group */
1412 case 515: /* Is a member of? */
1418 case 504: /* Name to ID */
1422 j
= EXTRACT_32BITS(bp
);
1423 bp
+= sizeof(int32_t);
1426 * Who designed this chicken-shit protocol?
1428 * Each character is stored as a 32-bit
1432 for (i
= 0; i
< j
; i
++) {
1439 case 505: /* Id to name */
1444 i
= EXTRACT_32BITS(bp
);
1445 bp
+= sizeof(int32_t);
1446 for (j
= 0; j
< i
; j
++)
1452 case 509: /* New entry */
1459 case 511: /* Set max */
1465 case 513: /* Change entry */
1474 case 520: /* Update entry */
1491 * Handle replies to the AFS protection service
1495 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1497 struct rx_header
*rxh
;
1500 if (length
< (int)sizeof(struct rx_header
))
1503 rxh
= (struct rx_header
*) bp
;
1506 * Print out the afs call we're invoking. The table used here was
1507 * gleaned from ptserver/ptint.xg. Check to see if it's a
1508 * Ubik call, however.
1513 if (is_ubik(opcode
)) {
1514 ubik_reply_print(bp
, length
, opcode
);
1518 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1520 bp
+= sizeof(struct rx_header
);
1523 * If it was a data packet, interpret the response
1526 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1528 case 504: /* Name to ID */
1533 i
= EXTRACT_32BITS(bp
);
1534 bp
+= sizeof(int32_t);
1535 for (j
= 0; j
< i
; j
++)
1541 case 505: /* ID to name */
1545 j
= EXTRACT_32BITS(bp
);
1546 bp
+= sizeof(int32_t);
1549 * Who designed this chicken-shit protocol?
1551 * Each character is stored as a 32-bit
1555 for (i
= 0; i
< j
; i
++) {
1562 case 508: /* Get CPS */
1563 case 514: /* List elements */
1564 case 517: /* List owned */
1565 case 518: /* Get CPS2 */
1566 case 519: /* Get host CPS */
1570 j
= EXTRACT_32BITS(bp
);
1571 bp
+= sizeof(int32_t);
1572 for (i
= 0; i
< j
; i
++) {
1579 case 510: /* List max */
1590 * Otherwise, just print out the return code
1603 * Handle calls to the AFS volume location database service
1607 vldb_print(register const u_char
*bp
, int length
)
1612 if (length
<= (int)sizeof(struct rx_header
))
1615 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1620 * Print out the afs call we're invoking. The table used here was
1621 * gleaned from vlserver/vldbint.xg
1624 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1628 if (is_ubik(vldb_op
)) {
1632 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1635 * Decode some of the arguments to the VLDB calls
1638 bp
+= sizeof(struct rx_header
) + 4;
1641 case 501: /* Create new volume */
1642 case 517: /* Create entry N */
1645 case 502: /* Delete entry */
1646 case 503: /* Get entry by ID */
1647 case 507: /* Update entry */
1648 case 508: /* Set lock */
1649 case 509: /* Release lock */
1650 case 518: /* Get entry by ID N */
1653 TCHECK2(bp
[0], sizeof(int32_t));
1654 i
= EXTRACT_32BITS(bp
);
1655 bp
+= sizeof(int32_t);
1657 printf(" type %s", voltype
[i
]);
1659 case 504: /* Get entry by name */
1660 case 519: /* Get entry by name N */
1661 case 524: /* Update entry by name */
1662 case 527: /* Get entry by name U */
1665 case 505: /* Get new vol id */
1669 case 506: /* Replace entry */
1670 case 520: /* Replace entry N */
1673 TCHECK2(bp
[0], sizeof(int32_t));
1674 i
= EXTRACT_32BITS(bp
);
1675 bp
+= sizeof(int32_t);
1677 printf(" type %s", voltype
[i
]);
1680 case 510: /* List entry */
1681 case 521: /* List entry N */
1696 * Handle replies to the AFS volume location database service
1700 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1702 struct rx_header
*rxh
;
1705 if (length
< (int)sizeof(struct rx_header
))
1708 rxh
= (struct rx_header
*) bp
;
1711 * Print out the afs call we're invoking. The table used here was
1712 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1713 * Ubik call, however.
1718 if (is_ubik(opcode
)) {
1719 ubik_reply_print(bp
, length
, opcode
);
1723 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1725 bp
+= sizeof(struct rx_header
);
1728 * If it was a data packet, interpret the response
1731 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1733 case 510: /* List entry */
1736 printf(" nextindex");
1738 case 503: /* Get entry by id */
1739 case 504: /* Get entry by name */
1740 { unsigned long nservers
, j
;
1742 TCHECK2(bp
[0], sizeof(int32_t));
1743 bp
+= sizeof(int32_t);
1744 printf(" numservers");
1745 TCHECK2(bp
[0], sizeof(int32_t));
1746 nservers
= EXTRACT_32BITS(bp
);
1747 bp
+= sizeof(int32_t);
1748 printf(" %lu", nservers
);
1750 for (i
= 0; i
< 8; i
++) {
1751 TCHECK2(bp
[0], sizeof(int32_t));
1754 intoa(((struct in_addr
*) bp
)->s_addr
));
1755 bp
+= sizeof(int32_t);
1757 printf(" partitions");
1758 for (i
= 0; i
< 8; i
++) {
1759 TCHECK2(bp
[0], sizeof(int32_t));
1760 j
= EXTRACT_32BITS(bp
);
1761 if (i
< nservers
&& j
<= 26)
1762 printf(" %c", 'a' + (int)j
);
1763 else if (i
< nservers
)
1765 bp
+= sizeof(int32_t);
1767 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1768 bp
+= 8 * sizeof(int32_t);
1777 case 505: /* Get new volume ID */
1781 case 521: /* List entry */
1782 case 529: /* List entry U */
1785 printf(" nextindex");
1787 case 518: /* Get entry by ID N */
1788 case 519: /* Get entry by name N */
1789 { unsigned long nservers
, j
;
1791 printf(" numservers");
1792 TCHECK2(bp
[0], sizeof(int32_t));
1793 nservers
= EXTRACT_32BITS(bp
);
1794 bp
+= sizeof(int32_t);
1795 printf(" %lu", nservers
);
1797 for (i
= 0; i
< 13; i
++) {
1798 TCHECK2(bp
[0], sizeof(int32_t));
1801 intoa(((struct in_addr
*) bp
)->s_addr
));
1802 bp
+= sizeof(int32_t);
1804 printf(" partitions");
1805 for (i
= 0; i
< 13; i
++) {
1806 TCHECK2(bp
[0], sizeof(int32_t));
1807 j
= EXTRACT_32BITS(bp
);
1808 if (i
< nservers
&& j
<= 26)
1809 printf(" %c", 'a' + (int)j
);
1810 else if (i
< nservers
)
1812 bp
+= sizeof(int32_t);
1814 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1815 bp
+= 13 * sizeof(int32_t);
1824 case 526: /* Get entry by ID U */
1825 case 527: /* Get entry by name U */
1826 { unsigned long nservers
, j
;
1828 printf(" numservers");
1829 TCHECK2(bp
[0], sizeof(int32_t));
1830 nservers
= EXTRACT_32BITS(bp
);
1831 bp
+= sizeof(int32_t);
1832 printf(" %lu", nservers
);
1834 for (i
= 0; i
< 13; i
++) {
1843 TCHECK2(bp
[0], 4 * 13);
1845 printf(" partitions");
1846 for (i
= 0; i
< 13; i
++) {
1847 TCHECK2(bp
[0], sizeof(int32_t));
1848 j
= EXTRACT_32BITS(bp
);
1849 if (i
< nservers
&& j
<= 26)
1850 printf(" %c", 'a' + (int)j
);
1851 else if (i
< nservers
)
1853 bp
+= sizeof(int32_t);
1855 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1856 bp
+= 13 * sizeof(int32_t);
1870 * Otherwise, just print out the return code
1883 * Handle calls to the AFS Kerberos Authentication service
1887 kauth_print(register const u_char
*bp
, int length
)
1891 if (length
<= (int)sizeof(struct rx_header
))
1894 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
1899 * Print out the afs call we're invoking. The table used here was
1900 * gleaned from kauth/kauth.rg
1903 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1907 if (is_ubik(kauth_op
)) {
1913 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1916 * Decode some of the arguments to the KA calls
1919 bp
+= sizeof(struct rx_header
) + 4;
1922 case 1: /* Authenticate old */;
1923 case 21: /* Authenticate */
1924 case 22: /* Authenticate-V2 */
1925 case 2: /* Change PW */
1926 case 5: /* Set fields */
1927 case 6: /* Create user */
1928 case 7: /* Delete user */
1929 case 8: /* Get entry */
1930 case 14: /* Unlock */
1931 case 15: /* Lock status */
1932 printf(" principal");
1936 case 3: /* GetTicket-old */
1937 case 23: /* GetTicket */
1944 TCHECK2(bp
[0], sizeof(int32_t));
1945 i
= (int) EXTRACT_32BITS(bp
);
1946 bp
+= sizeof(int32_t);
1949 printf(" principal");
1954 case 4: /* Set Password */
1955 printf(" principal");
1961 case 12: /* Get password */
1972 printf(" [|kauth]");
1976 * Handle replies to the AFS Kerberos Authentication Service
1980 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1982 struct rx_header
*rxh
;
1984 if (length
<= (int)sizeof(struct rx_header
))
1987 rxh
= (struct rx_header
*) bp
;
1990 * Print out the afs call we're invoking. The table used here was
1991 * gleaned from kauth/kauth.rg
1996 if (is_ubik(opcode
)) {
1997 ubik_reply_print(bp
, length
, opcode
);
2001 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
2003 bp
+= sizeof(struct rx_header
);
2006 * If it was a data packet, interpret the response.
2009 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2010 /* Well, no, not really. Leave this for later */
2014 * Otherwise, just print out the return code
2023 printf(" [|kauth]");
2027 * Handle calls to the AFS Volume location service
2031 vol_print(register const u_char
*bp
, int length
)
2035 if (length
<= (int)sizeof(struct rx_header
))
2038 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2043 * Print out the afs call we're invoking. The table used here was
2044 * gleaned from volser/volint.xg
2047 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2049 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
2051 bp
+= sizeof(struct rx_header
) + 4;
2054 case 100: /* Create volume */
2055 printf(" partition");
2064 case 101: /* Delete volume */
2065 case 107: /* Get flags */
2069 case 102: /* Restore */
2075 case 103: /* Forward */
2076 printf(" fromtrans");
2078 printf(" fromdate");
2081 printf(" desttrans");
2084 case 104: /* End trans */
2088 case 105: /* Clone */
2091 printf(" purgevol");
2098 case 106: /* Set flags */
2104 case 108: /* Trans create */
2107 printf(" partition");
2112 case 109: /* Dump */
2113 case 655537: /* Get size */
2114 printf(" fromtrans");
2116 printf(" fromdate");
2119 case 110: /* Get n-th volume */
2123 case 111: /* Set forwarding */
2129 case 112: /* Get name */
2130 case 113: /* Get status */
2133 case 114: /* Signal restore */
2143 case 116: /* List volumes */
2144 printf(" partition");
2149 case 117: /* Set id types */
2163 case 119: /* Partition info */
2167 case 120: /* Reclone */
2171 case 121: /* List one volume */
2172 case 122: /* Nuke volume */
2173 case 124: /* Extended List volumes */
2174 case 125: /* Extended List one volume */
2175 case 65536: /* Convert RO to RW volume */
2181 case 123: /* Set date */
2187 case 126: /* Set info */
2191 case 128: /* Forward multiple */
2192 printf(" fromtrans");
2194 printf(" fromdate");
2199 j
= EXTRACT_32BITS(bp
);
2200 bp
+= sizeof(int32_t);
2201 for (i
= 0; i
< j
; i
++) {
2210 case 65538: /* Dump version 2 */
2211 printf(" fromtrans");
2213 printf(" fromdate");
2228 * Handle replies to the AFS Volume Service
2232 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2234 struct rx_header
*rxh
;
2236 if (length
<= (int)sizeof(struct rx_header
))
2239 rxh
= (struct rx_header
*) bp
;
2242 * Print out the afs call we're invoking. The table used here was
2243 * gleaned from volser/volint.xg
2246 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
2248 bp
+= sizeof(struct rx_header
);
2251 * If it was a data packet, interpret the response.
2254 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
2256 case 100: /* Create volume */
2262 case 104: /* End transaction */
2265 case 105: /* Clone */
2269 case 107: /* Get flags */
2272 case 108: /* Transaction create */
2276 case 110: /* Get n-th volume */
2279 printf(" partition");
2282 case 112: /* Get name */
2285 case 113: /* Get status */
2288 printf(" nextuniq");
2292 printf(" parentid");
2300 printf(" maxquota");
2302 printf(" minquota");
2319 case 115: /* Old list partitions */
2321 case 116: /* List volumes */
2322 case 121: /* List one volume */
2326 j
= EXTRACT_32BITS(bp
);
2327 bp
+= sizeof(int32_t);
2328 for (i
= 0; i
< j
; i
++) {
2334 bp
+= sizeof(int32_t) * 21;
2349 * Otherwise, just print out the return code
2362 * Handle calls to the AFS BOS service
2366 bos_print(register const u_char
*bp
, int length
)
2370 if (length
<= (int)sizeof(struct rx_header
))
2373 if (snapend
- bp
+ 1 <= (int)(sizeof(struct rx_header
) + sizeof(int32_t))) {
2378 * Print out the afs call we're invoking. The table used here was
2379 * gleaned from bozo/bosint.xg
2382 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2384 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2387 * Decode some of the arguments to the BOS calls
2390 bp
+= sizeof(struct rx_header
) + 4;
2393 case 80: /* Create B node */
2396 printf(" instance");
2399 case 81: /* Delete B node */
2400 case 83: /* Get status */
2401 case 85: /* Get instance info */
2402 case 87: /* Add super user */
2403 case 88: /* Delete super user */
2404 case 93: /* Set cell name */
2405 case 96: /* Add cell host */
2406 case 97: /* Delete cell host */
2407 case 104: /* Restart */
2408 case 106: /* Uninstall */
2409 case 108: /* Exec */
2410 case 112: /* Getlog */
2411 case 114: /* Get instance strings */
2414 case 82: /* Set status */
2415 case 98: /* Set T status */
2420 case 86: /* Get instance parm */
2425 case 84: /* Enumerate instance */
2426 case 89: /* List super users */
2427 case 90: /* List keys */
2428 case 91: /* Add key */
2429 case 92: /* Delete key */
2430 case 95: /* Get cell host */
2433 case 105: /* Install */
2453 * Handle replies to the AFS BOS Service
2457 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2459 struct rx_header
*rxh
;
2461 if (length
<= (int)sizeof(struct rx_header
))
2464 rxh
= (struct rx_header
*) bp
;
2467 * Print out the afs call we're invoking. The table used here was
2468 * gleaned from volser/volint.xg
2471 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2473 bp
+= sizeof(struct rx_header
);
2476 * If it was a data packet, interpret the response.
2479 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2480 /* Well, no, not really. Leave this for later */
2484 * Otherwise, just print out the return code
2497 * Check to see if this is a Ubik opcode.
2501 is_ubik(u_int32_t opcode
)
2503 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2504 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2511 * Handle Ubik opcodes to any one of the replicated database services
2515 ubik_print(register const u_char
*bp
)
2521 * Print out the afs call we're invoking. The table used here was
2522 * gleaned from ubik/ubik_int.xg
2525 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2527 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2530 * Decode some of the arguments to the Ubik calls
2533 bp
+= sizeof(struct rx_header
) + 4;
2536 case 10000: /* Beacon */
2538 temp
= EXTRACT_32BITS(bp
);
2539 bp
+= sizeof(int32_t);
2540 printf(" syncsite %s", temp
? "yes" : "no");
2541 printf(" votestart");
2543 printf(" dbversion");
2548 case 10003: /* Get sync site */
2552 case 20000: /* Begin */
2553 case 20001: /* Commit */
2554 case 20007: /* Abort */
2555 case 20008: /* Release locks */
2556 case 20010: /* Writev */
2560 case 20002: /* Lock */
2569 temp
= EXTRACT_32BITS(bp
);
2570 bp
+= sizeof(int32_t);
2571 tok2str(ubik_lock_types
, "type %d", temp
);
2573 case 20003: /* Write */
2581 case 20005: /* Get file */
2585 case 20006: /* Send file */
2590 printf(" dbversion");
2593 case 20009: /* Truncate */
2601 case 20012: /* Set version */
2604 printf(" oldversion");
2606 printf(" newversion");
2620 * Handle Ubik replies to any one of the replicated database services
2624 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2626 struct rx_header
*rxh
;
2628 if (length
< (int)sizeof(struct rx_header
))
2631 rxh
= (struct rx_header
*) bp
;
2634 * Print out the ubik call we're invoking. This table was gleaned
2635 * from ubik/ubik_int.xg
2638 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2640 bp
+= sizeof(struct rx_header
);
2643 * If it was a data packet, print out the arguments to the Ubik calls
2646 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2648 case 10000: /* Beacon */
2651 case 20004: /* Get version */
2652 printf(" dbversion");
2660 * Otherwise, print out "yes" it it was a beacon packet (because
2661 * that's how yes votes are returned, go figure), otherwise
2662 * just print out the error code.
2667 case 10000: /* Beacon */
2668 printf(" vote yes until");
2683 * Handle RX ACK packets.
2687 rx_ack_print(register const u_char
*bp
, int length
)
2689 struct rx_ackPacket
*rxa
;
2691 u_int32_t firstPacket
;
2693 if (length
< (int)sizeof(struct rx_header
))
2696 bp
+= sizeof(struct rx_header
);
2699 * This may seem a little odd .... the rx_ackPacket structure
2700 * contains an array of individual packet acknowledgements
2701 * (used for selective ack/nack), but since it's variable in size,
2702 * we don't want to truncate based on the size of the whole
2703 * rx_ackPacket structure.
2706 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2708 rxa
= (struct rx_ackPacket
*) bp
;
2709 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2712 * Print out a few useful things from the ack packet structure
2716 printf(" bufspace %d maxskew %d",
2717 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2718 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2720 firstPacket
= EXTRACT_32BITS(&rxa
->firstPacket
);
2721 printf(" first %d serial %d reason %s",
2722 firstPacket
, EXTRACT_32BITS(&rxa
->serial
),
2723 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2726 * Okay, now we print out the ack array. The way _this_ works
2727 * is that we start at "first", and step through the ack array.
2728 * If we have a contiguous range of acks/nacks, try to
2729 * collapse them into a range.
2731 * If you're really clever, you might have noticed that this
2732 * doesn't seem quite correct. Specifically, due to structure
2733 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2734 * yield the start of the ack array (because RX_MAXACKS is 255
2735 * and the structure will likely get padded to a 2 or 4 byte
2736 * boundary). However, this is the way it's implemented inside
2737 * of AFS - the start of the extra fields are at
2738 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2739 * the exact start of the ack array. Sigh. That's why we aren't
2740 * using bp, but instead use rxa->acks[]. But nAcks gets added
2741 * to bp after this, so bp ends up at the right spot. Go figure.
2744 if (rxa
->nAcks
!= 0) {
2746 TCHECK2(bp
[0], rxa
->nAcks
);
2749 * Sigh, this is gross, but it seems to work to collapse
2753 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2754 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2757 * I figured this deserved _some_ explanation.
2758 * First, print "acked" and the packet seq
2759 * number if this is the first time we've
2760 * seen an acked packet.
2770 * Otherwise, if the there is a skip in
2771 * the range (such as an nacked packet in
2772 * the middle of some acked packets),
2773 * then print the current packet number
2774 * seperated from the last number by
2778 else if (last
!= i
- 1) {
2779 printf(",%d", firstPacket
+ i
);
2784 * We always set last to the value of
2785 * the last ack we saw. Conversely, start
2786 * is set to the value of the first ack
2787 * we saw in a range.
2793 * Okay, this bit a code gets executed when
2794 * we hit a nack ... in _this_ case we
2795 * want to print out the range of packets
2796 * that were acked, so we need to print
2797 * the _previous_ packet number seperated
2798 * from the first by a dash (-). Since we
2799 * already printed the first packet above,
2800 * just print the final packet. Don't
2801 * do this if there will be a single-length
2804 } else if (last
== i
- 1 && start
!= last
)
2805 printf("-%d", firstPacket
+ i
- 1);
2808 * So, what's going on here? We ran off the end of the
2809 * ack list, and if we got a range we need to finish it up.
2810 * So we need to determine if the last packet in the list
2811 * was an ack (if so, then last will be set to it) and
2812 * we need to see if the last range didn't start with the
2813 * last packet (because if it _did_, then that would mean
2814 * that the packet number has already been printed and
2815 * we don't need to print it again).
2818 if (last
== i
- 1 && start
!= last
)
2819 printf("-%d", firstPacket
+ i
- 1);
2822 * Same as above, just without comments
2825 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2826 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2828 printf(" nacked %d",
2831 } else if (last
!= i
- 1) {
2832 printf(",%d", firstPacket
+ i
);
2836 } else if (last
== i
- 1 && start
!= last
)
2837 printf("-%d", firstPacket
+ i
- 1);
2839 if (last
== i
- 1 && start
!= last
)
2840 printf("-%d", firstPacket
+ i
- 1);
2847 * These are optional fields; depending on your version of AFS,
2848 * you may or may not see them
2851 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2867 printf(" maxpackets");