]>
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 "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.16 2000-09-23 08:54:39 guy Exp $";
26 #include <sys/param.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
31 #include <netinet/in_systm.h>
32 #include <arpa/inet.h>
34 #include "interface.h"
35 #include "addrtoname.h"
38 #undef NOERROR /* Solaris sucks */
39 #include <arpa/nameser.h>
45 static struct tok rx_types
[] = {
46 { RX_PACKET_TYPE_DATA
, "data" },
47 { RX_PACKET_TYPE_ACK
, "ack" },
48 { RX_PACKET_TYPE_BUSY
, "busy" },
49 { RX_PACKET_TYPE_ABORT
, "abort" },
50 { RX_PACKET_TYPE_ACKALL
, "ackall" },
51 { RX_PACKET_TYPE_CHALLENGE
, "challenge" },
52 { RX_PACKET_TYPE_RESPONSE
, "response" },
53 { RX_PACKET_TYPE_DEBUG
, "debug" },
54 { RX_PACKET_TYPE_PARAMS
, "params" },
55 { RX_PACKET_TYPE_VERSION
, "version" },
59 static struct tok rx_flags
[] = {
60 { RX_CLIENT_INITIATED
, "client-init" },
61 { RX_REQUEST_ACK
, "req-ack" },
62 { RX_LAST_PACKET
, "last-pckt" },
63 { RX_MORE_PACKETS
, "more-pckts" },
64 { RX_FREE_PACKET
, "free-pckt" }
67 static struct tok fs_req
[] = {
68 { 130, "fetch-data" },
70 { 132, "fetch-status" },
71 { 133, "store-data" },
73 { 135, "store-status" },
74 { 136, "remove-file" },
75 { 137, "create-file" },
81 { 143, "oldsetlock" },
82 { 144, "oldextlock" },
83 { 145, "oldrellock" },
86 { 148, "get-vlinfo" },
87 { 149, "get-vlstats" },
88 { 150, "set-vlstats" },
89 { 151, "get-rootvl" },
90 { 152, "check-token" },
92 { 154, "nget-vlinfo" },
99 { 161, "dfs-lookup" },
100 { 162, "dfs-flushcps" },
101 { 163, "dfs-symlink" },
105 static struct tok cb_req
[] = {
114 { 212, "whoareyou" },
116 { 214, "probeuuid" },
120 static struct tok pt_req
[] = {
122 { 501, "where-is-it" },
123 { 502, "dump-entry" },
124 { 503, "add-to-group" },
125 { 504, "name-to-id" },
126 { 505, "id-to-name" },
128 { 507, "remove-from-group" },
130 { 509, "new-entry" },
133 { 512, "list-entry" },
134 { 513, "change-entry" },
135 { 514, "list-elements" },
136 { 515, "same-mbr-of" },
137 { 516, "set-fld-sentry" },
138 { 517, "list-owned" },
140 { 519, "get-host-cps" },
141 { 520, "update-entry" },
145 static struct tok vldb_req
[] = {
146 { 501, "create-entry" },
147 { 502, "delete-entry" },
148 { 503, "get-entry-by-id" },
149 { 504, "get-entry-by-name" },
150 { 505, "get-new-volume-id" },
151 { 506, "replace-entry" },
152 { 507, "update-entry" },
154 { 509, "releaselock" },
155 { 510, "list-entry" },
156 { 511, "list-attrib" },
157 { 512, "linked-list" },
158 { 513, "get-stats" },
160 { 515, "get-addrs" },
161 { 516, "change-addr" },
162 { 517, "create-entry-n" },
163 { 518, "get-entry-by-id-n" },
164 { 519, "get-entry-by-name-n" },
165 { 520, "replace-entry-n" },
166 { 521, "list-entry-n" },
167 { 522, "list-attrib-n" },
168 { 523, "linked-list-n" },
169 { 524, "update-entry-by-name" },
170 { 525, "create-entry-u" },
171 { 526, "get-entry-by-id-u" },
172 { 527, "get-entry-by-name-u" },
173 { 528, "replace-entry-u" },
174 { 529, "list-entry-u" },
175 { 530, "list-attrib-u" },
176 { 531, "linked-list-u" },
178 { 533, "get-addrs-u" },
182 static struct tok kauth_req
[] = {
184 { 21, "authenticate" },
185 { 22, "authenticate-v2" },
187 { 3, "get-ticket-old" },
188 { 23, "get-ticket" },
191 { 6, "create-user" },
192 { 7, "delete-user" },
198 { 13, "get-random-key" },
200 { 15, "lock-status" },
204 static struct tok vol_req
[] = {
205 { 100, "create-volume" },
206 { 101, "delete-volume" },
209 { 104, "end-trans" },
211 { 106, "set-flags" },
212 { 107, "get-flags" },
213 { 108, "trans-create" },
215 { 110, "get-nth-volume" },
216 { 111, "set-forwarding" },
218 { 113, "get-status" },
219 { 114, "sig-restore" },
220 { 115, "list-partitions" },
221 { 116, "list-volumes" },
222 { 117, "set-id-types" },
224 { 119, "partition-info" },
226 { 121, "list-one-volume" },
229 { 124, "x-list-volumes" },
230 { 125, "x-list-one-volume" },
232 { 127, "x-list-partitions" },
233 { 128, "forward-multiple" },
237 static struct tok bos_req
[] = {
238 { 80, "create-bnode" },
239 { 81, "delete-bnode" },
240 { 82, "set-status" },
241 { 83, "get-status" },
242 { 84, "enumerate-instance" },
243 { 85, "get-instance-info" },
244 { 86, "get-instance-parm" },
245 { 87, "add-superuser" },
246 { 88, "delete-superuser" },
247 { 89, "list-superusers" },
250 { 92, "delete-key" },
251 { 93, "set-cell-name" },
252 { 94, "get-cell-name" },
253 { 95, "get-cell-host" },
254 { 96, "add-cell-host" },
255 { 97, "delete-cell-host" },
256 { 98, "set-t-status" },
257 { 99, "shutdown-all" },
258 { 100, "restart-all" },
259 { 101, "startup-all" },
260 { 102, "set-noauth-flag" },
263 { 105, "start-bozo-install" },
264 { 106, "uninstall" },
265 { 107, "get-dates" },
268 { 110, "set-restart-time" },
269 { 111, "get-restart-time" },
270 { 112, "start-bozo-log" },
272 { 114, "get-instance-strings" },
276 static struct tok ubik_req
[] = {
277 { 10000, "vote-beacon" },
278 { 10001, "vote-debug-old" },
279 { 10002, "vote-sdebug-old" },
280 { 10003, "vote-getsyncsite" },
281 { 10004, "vote-debug" },
282 { 10005, "vote-sdebug" },
283 { 20000, "disk-begin" },
284 { 20001, "disk-commit" },
285 { 20002, "disk-lock" },
286 { 20003, "disk-write" },
287 { 20004, "disk-getversion" },
288 { 20005, "disk-getfile" },
289 { 20006, "disk-sendfile" },
290 { 20007, "disk-abort" },
291 { 20008, "disk-releaselocks" },
292 { 20009, "disk-truncate" },
293 { 20010, "disk-probe" },
294 { 20011, "disk-writev" },
295 { 20012, "disk-interfaceaddr" },
296 { 20013, "disk-setversion" },
300 #define VOTE_LOW 10000
301 #define VOTE_HIGH 10005
302 #define DISK_LOW 20000
303 #define DISK_HIGH 20013
305 static struct tok cb_types
[] = {
312 static struct tok ubik_lock_types
[] = {
319 static char *voltype
[] = { "read-write", "read-only", "backup" };
321 static struct tok afs_fs_errors
[] = {
322 { 101, "salvage volume" },
323 { 102, "no such vnode" },
324 { 103, "no such volume" },
325 { 104, "volume exist" },
326 { 105, "no service" },
327 { 106, "volume offline" },
328 { 107, "voline online" },
330 { 109, "diskquota exceeded" },
331 { 110, "volume busy" },
332 { 111, "volume moved" },
333 { 112, "AFS IO error" },
334 { -100, "restarting fileserver" },
339 * Reasons for acknowledging a packet
342 static struct tok rx_ack_reasons
[] = {
343 { 1, "ack requested" },
344 { 2, "duplicate packet" },
345 { 3, "out of sequence" },
346 { 4, "exceeds window" },
347 { 5, "no buffer space" },
349 { 7, "ping response" },
355 * Cache entries we keep around so we can figure out the RX opcode
356 * numbers for replies. This allows us to make sense of RX reply packets.
359 struct rx_cache_entry
{
360 u_int32_t callnum
; /* Call number (net order) */
361 struct in_addr client
; /* client IP address (net order) */
362 struct in_addr server
; /* server IP address (net order) */
363 int dport
; /* server port (host order) */
364 u_short serviceId
; /* Service identifier (net order) */
365 u_int32_t opcode
; /* RX opcode (host order) */
368 #define RX_CACHE_SIZE 64
370 static struct rx_cache_entry rx_cache
[RX_CACHE_SIZE
];
372 static int rx_cache_next
= 0;
373 static int rx_cache_hint
= 0;
374 static void rx_cache_insert(const u_char
*, const struct ip
*, int, int);
375 static int rx_cache_find(const struct rx_header
*, const struct ip
*,
378 static void ack_print(const u_char
*, int);
379 static void fs_print(const u_char
*, int);
380 static void fs_reply_print(const u_char
*, int, int32_t);
381 static void acl_print(u_char
*, u_char
*);
382 static void cb_print(const u_char
*, int);
383 static void cb_reply_print(const u_char
*, int, int32_t);
384 static void prot_print(const u_char
*, int);
385 static void prot_reply_print(const u_char
*, int, int32_t);
386 static void vldb_print(const u_char
*, int);
387 static void vldb_reply_print(const u_char
*, int, int32_t);
388 static void kauth_print(const u_char
*, int);
389 static void kauth_reply_print(const u_char
*, int, int32_t);
390 static void vol_print(const u_char
*, int);
391 static void vol_reply_print(const u_char
*, int, int32_t);
392 static void bos_print(const u_char
*, int);
393 static void bos_reply_print(const u_char
*, int, int32_t);
394 static void ubik_print(const u_char
*, int);
395 static void ubik_reply_print(const u_char
*, int, int32_t);
397 static void rx_ack_print(const u_char
*, int);
399 static int is_ubik(u_int32_t
);
402 * Handle the rx-level packet. See if we know what port it's going to so
403 * we can peek at the afs call inside
407 rx_print(register const u_char
*bp
, int length
, int sport
, int dport
,
410 register struct rx_header
*rxh
;
414 if (snapend
- bp
< sizeof (struct rx_header
)) {
415 printf(" [|rx] (%d)", length
);
419 rxh
= (struct rx_header
*) bp
;
421 printf(" rx %s", tok2str(rx_types
, "type %d", rxh
->type
));
427 printf(" cid %08x call# %d",
428 (int) EXTRACT_32BITS(&rxh
->cid
),
429 (int) EXTRACT_32BITS(&rxh
->callNumber
));
431 printf(" seq %d ser %d",
432 (int) EXTRACT_32BITS(&rxh
->seq
),
433 (int) EXTRACT_32BITS(&rxh
->serial
));
436 printf(" secindex %d serviceid %hu",
437 (int) rxh
->securityIndex
,
438 EXTRACT_16BITS(&rxh
->serviceId
));
441 for (i
= 0; i
< NUM_RX_FLAGS
; i
++) {
442 if (rxh
->flags
& rx_flags
[i
].v
) {
449 printf("<%s>", rx_flags
[i
].s
);
455 * Try to handle AFS calls that we know about. Check the destination
456 * port and make sure it's a data packet. Also, make sure the
457 * seq number is 1 (because otherwise it's a continuation packet,
458 * and we can't interpret that). Also, seems that reply packets
459 * do not have the client-init flag set, so we check for that
463 if (rxh
->type
== RX_PACKET_TYPE_ACK
)
464 ack_print(bp
, length
);
465 else if (rxh
->type
== RX_PACKET_TYPE_DATA
&&
466 EXTRACT_32BITS(&rxh
->seq
) == 1 &&
467 rxh
->flags
& RX_CLIENT_INITIATED
) {
470 * Insert this call into the call cache table, so we
471 * have a chance to print out replies
474 rx_cache_insert(bp
, (const struct ip
*) bp2
, dport
, length
);
477 case FS_RX_PORT
: /* AFS file service */
478 fs_print(bp
, length
);
480 case CB_RX_PORT
: /* AFS callback service */
481 cb_print(bp
, length
);
483 case PROT_RX_PORT
: /* AFS protection service */
484 prot_print(bp
, length
);
486 case VLDB_RX_PORT
: /* AFS VLDB service */
487 vldb_print(bp
, length
);
489 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
490 kauth_print(bp
, length
);
492 case VOL_RX_PORT
: /* AFS Volume service */
493 vol_print(bp
, length
);
495 case BOS_RX_PORT
: /* AFS BOS service */
496 bos_print(bp
, length
);
503 * If it's a reply (client-init is _not_ set, but seq is one)
504 * then look it up in the cache. If we find it, call the reply
505 * printing functions Note that we handle abort packets here,
506 * because printing out the return code can be useful at times.
509 } else if (((rxh
->type
== RX_PACKET_TYPE_DATA
&&
510 EXTRACT_32BITS(&rxh
->seq
) == 1) ||
511 rxh
->type
== RX_PACKET_TYPE_ABORT
) &&
512 (rxh
->flags
& RX_CLIENT_INITIATED
) == 0 &&
513 rx_cache_find(rxh
, (const struct ip
*) bp2
,
517 case FS_RX_PORT
: /* AFS file service */
518 fs_reply_print(bp
, length
, opcode
);
520 case CB_RX_PORT
: /* AFS callback service */
521 cb_reply_print(bp
, length
, opcode
);
523 case PROT_RX_PORT
: /* AFS PT service */
524 prot_reply_print(bp
, length
, opcode
);
526 case VLDB_RX_PORT
: /* AFS VLDB service */
527 vldb_reply_print(bp
, length
, opcode
);
529 case KAUTH_RX_PORT
: /* AFS Kerberos auth service */
530 kauth_reply_print(bp
, length
, opcode
);
532 case VOL_RX_PORT
: /* AFS Volume service */
533 vol_reply_print(bp
, length
, opcode
);
535 case BOS_RX_PORT
: /* AFS BOS service */
536 bos_reply_print(bp
, length
, opcode
);
543 * If it's an RX ack packet, then use the appropriate ack decoding
544 * function (there isn't any service-specific information in the
545 * ack packet, so we can use one for all AFS services)
548 } else if (rxh
->type
== RX_PACKET_TYPE_ACK
)
549 rx_ack_print(bp
, length
);
552 printf(" (%d)", length
);
556 * Insert an entry into the cache. Taken from print-nfs.c
560 rx_cache_insert(const u_char
*bp
, const struct ip
*ip
, int dport
,
563 struct rx_cache_entry
*rxent
;
564 const struct rx_header
*rxh
= (const struct rx_header
*) bp
;
566 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t))
569 rxent
= &rx_cache
[rx_cache_next
];
571 if (++rx_cache_next
>= RX_CACHE_SIZE
)
574 rxent
->callnum
= rxh
->callNumber
;
575 rxent
->client
= ip
->ip_src
;
576 rxent
->server
= ip
->ip_dst
;
577 rxent
->dport
= dport
;
578 rxent
->serviceId
= rxh
->serviceId
;
579 rxent
->opcode
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
583 * Lookup an entry in the cache. Also taken from print-nfs.c
585 * Note that because this is a reply, we're looking at the _source_
590 rx_cache_find(const struct rx_header
*rxh
, const struct ip
*ip
, int sport
,
594 struct rx_cache_entry
*rxent
;
595 u_int32_t clip
= ip
->ip_dst
.s_addr
;
596 u_int32_t sip
= ip
->ip_src
.s_addr
;
598 /* Start the search where we last left off */
602 rxent
= &rx_cache
[i
];
603 if (rxent
->callnum
== rxh
->callNumber
&&
604 rxent
->client
.s_addr
== clip
&&
605 rxent
->server
.s_addr
== sip
&&
606 rxent
->serviceId
== rxh
->serviceId
&&
607 rxent
->dport
== sport
) {
609 /* We got a match! */
612 *opcode
= rxent
->opcode
;
615 if (++i
> RX_CACHE_SIZE
)
617 } while (i
!= rx_cache_hint
);
619 /* Our search failed */
624 * These extrememly grody macros handle the printing of various AFS stuff.
627 #define FIDOUT() { unsigned long n1, n2, n3; \
628 TCHECK2(bp[0], sizeof(int32_t) * 3); \
629 n1 = EXTRACT_32BITS(bp); \
630 bp += sizeof(int32_t); \
631 n2 = EXTRACT_32BITS(bp); \
632 bp += sizeof(int32_t); \
633 n3 = EXTRACT_32BITS(bp); \
634 bp += sizeof(int32_t); \
635 printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
638 #define STROUT(MAX) { int i; \
639 TCHECK2(bp[0], sizeof(int32_t)); \
640 i = (int) EXTRACT_32BITS(bp); \
641 bp += sizeof(int32_t); \
643 strncpy(s, (char *) bp, min(MAX, i)); \
645 printf(" \"%s\"", s); \
646 bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
649 #define INTOUT() { int i; \
650 TCHECK2(bp[0], sizeof(int32_t)); \
651 i = (int) EXTRACT_32BITS(bp); \
652 bp += sizeof(int32_t); \
656 #define UINTOUT() { unsigned long i; \
657 TCHECK2(bp[0], sizeof(int32_t)); \
658 i = EXTRACT_32BITS(bp); \
659 bp += sizeof(int32_t); \
663 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
664 TCHECK2(bp[0], sizeof(int32_t)); \
665 t = (time_t) EXTRACT_32BITS(bp); \
666 bp += sizeof(int32_t); \
667 tm = localtime(&t); \
668 strftime(str, 256, "%Y/%m/%d %T", tm); \
669 printf(" %s", str); \
672 #define STOREATTROUT() { unsigned long mask, i; \
673 TCHECK2(bp[0], (sizeof(int32_t)*6)); \
674 mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
675 if (mask) printf (" StoreStatus"); \
676 if (mask & 1) { printf(" date"); DATEOUT(); } \
677 else bp += sizeof(int32_t); \
678 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
679 if (mask & 2) printf(" owner %lu", i); \
680 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
681 if (mask & 4) printf(" group %lu", i); \
682 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
683 if (mask & 8) printf(" mode %lo", i & 07777); \
684 i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
685 if (mask & 16) printf(" segsize %lu", i); \
686 /* undocumented in 3.3 docu */ \
687 if (mask & 1024) printf(" fsync"); \
690 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
691 TCHECK2(bp[0], sizeof(int32_t) * 2); \
692 epoch = EXTRACT_32BITS(bp); \
693 bp += sizeof(int32_t); \
694 counter = EXTRACT_32BITS(bp); \
695 bp += sizeof(int32_t); \
696 printf(" %d.%d", epoch, counter); \
699 #define AFSUUIDOUT() {u_int32_t temp; int i; \
700 TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
701 temp = EXTRACT_32BITS(bp); \
702 bp += sizeof(u_int32_t); \
703 printf(" %08x", temp); \
704 temp = EXTRACT_32BITS(bp); \
705 bp += sizeof(u_int32_t); \
706 printf("%04x", temp); \
707 temp = EXTRACT_32BITS(bp); \
708 bp += sizeof(u_int32_t); \
709 printf("%04x", temp); \
710 for (i = 0; i < 8; i++) { \
711 temp = EXTRACT_32BITS(bp); \
712 bp += sizeof(u_int32_t); \
713 printf("%02x", (unsigned char) temp); \
718 * This is the sickest one of all
721 #define VECOUT(MAX) { char *sp; \
723 TCHECK2(bp[0], MAX * sizeof(int32_t)); \
725 for (k = 0; k < MAX; k++) { \
726 *sp++ = (char) EXTRACT_32BITS(bp); \
727 bp += sizeof(int32_t); \
730 printf(" \"%s\"", s); \
734 ack_print(register const u_char
*bp
, int length
)
742 if (length
<= sizeof(struct rx_header
))
745 bp
+= sizeof(struct rx_header
);
748 * Packets < firstPacket are implicitly acknowledged and may
749 * be discarded by the sender.
751 * Packets >= firstPacket+nAcks are implicitly NOT acknowledged.
753 * No packets with sequence numbers >= firstPacket should be
754 * discarded by the sender (they may thrown out at any time by
757 #define RX_ACK_REASONS "RDOXSprn"
758 /* Requested, Duplicate, Out_of_sequence, eXceeds_window, no_Space,
759 * Ping, ping_Response, No_{progress, particular_reason}.
762 struct rx_ackPacket
{
763 u_short bufferSpace
; /* Skip! */
764 u_short maxSkew
; /* Skip! */
766 u_long previousPacket
; /* Obsolete! */
767 u_long serial
; /* Serial that prompted the ack, */
768 u_char reason
; /* and the reason why. */
770 u_char acks
[RX_MAXACKS
]; /* Selective acks (not a bitmap). */
773 #define RX_ACK_TYPE_NACK 0
775 TCHECK2(bp
[0], 8); /* bufferSpace and maxSkew */
777 printf(" fir %u", (unsigned)EXTRACT_32BITS(bp
));
779 TCHECK2(bp
[0], 8); /* previousPacket and serial */
781 printf(" %u", (unsigned)EXTRACT_32BITS(bp
));
784 printf("%c", RX_ACK_REASONS
[(*bp
- 1) & 07u]);
785 bp
+= 1; /* reason */
790 for (i
= 0; i
< nAcks
; i
++) {
792 putchar(*bp
== RX_ACK_TYPE_NACK
? '-' : '*');
803 * Handle calls to the AFS file service (fs)
807 fs_print(register const u_char
*bp
, int length
)
813 if (length
<= sizeof(struct rx_header
))
816 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
821 * Print out the afs call we're invoking. The table used here was
822 * gleaned from fsint/afsint.xg
825 fs_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
827 printf(" fs call %s", tok2str(fs_req
, "op#%d", fs_op
));
830 * Print out arguments to some of the AFS calls. This stuff is
834 bp
+= sizeof(struct rx_header
) + 4;
837 * Sigh. This is gross. Ritchie forgive me.
841 case 130: /* Fetch data */
848 case 131: /* Fetch ACL */
849 case 132: /* Fetch Status */
850 case 143: /* Old set lock */
851 case 144: /* Old extend lock */
852 case 145: /* Old release lock */
853 case 156: /* Set lock */
854 case 157: /* Extend lock */
855 case 158: /* Release lock */
858 case 135: /* Store status */
862 case 133: /* Store data */
872 case 134: /* Store ACL */
874 char a
[AFSOPAQUEMAX
];
877 i
= EXTRACT_32BITS(bp
);
878 bp
+= sizeof(int32_t);
880 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
882 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
885 case 137: /* Create file */
886 case 141: /* MakeDir */
891 case 136: /* Remove file */
892 case 142: /* Remove directory */
896 case 138: /* Rename file */
904 case 139: /* Symlink */
916 case 148: /* Get volume info */
919 case 149: /* Get volume stats */
920 case 150: /* Set volume stats */
924 case 154: /* New get volume info */
928 case 155: /* Bulk stat */
932 j
= EXTRACT_32BITS(bp
);
933 bp
+= sizeof(int32_t);
935 for (i
= 0; i
< j
; i
++) {
954 * Handle replies to the AFS file service
958 fs_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
962 struct rx_header
*rxh
;
964 if (length
<= sizeof(struct rx_header
))
967 rxh
= (struct rx_header
*) bp
;
970 * Print out the afs call we're invoking. The table used here was
971 * gleaned from fsint/afsint.xg
974 printf(" fs reply %s", tok2str(fs_req
, "op#%d", opcode
));
976 bp
+= sizeof(struct rx_header
);
979 * If it was a data packet, interpret the response
982 if (rxh
->type
== RX_PACKET_TYPE_DATA
) {
984 case 131: /* Fetch ACL */
986 char a
[AFSOPAQUEMAX
];
988 i
= EXTRACT_32BITS(bp
);
989 bp
+= sizeof(int32_t);
991 strncpy(a
, (char *) bp
, min(AFSOPAQUEMAX
, i
));
993 acl_print((u_char
*) a
, (u_char
*) a
+ i
);
996 case 137: /* Create file */
997 case 141: /* MakeDir */
1001 case 151: /* Get root volume */
1002 printf(" root volume");
1005 case 153: /* Get time */
1011 } else if (rxh
->type
== RX_PACKET_TYPE_ABORT
) {
1015 * Otherwise, just print out the return code
1017 TCHECK2(bp
[0], sizeof(int32_t));
1018 i
= (int) EXTRACT_32BITS(bp
);
1019 bp
+= sizeof(int32_t);
1021 printf(" error %s", tok2str(afs_fs_errors
, "#%d", i
));
1023 printf(" strange fs reply of type %d", rxh
->type
);
1033 * Print out an AFS ACL string. An AFS ACL is a string that has the
1036 * <positive> <negative>
1040 * "positive" and "negative" are integers which contain the number of
1041 * positive and negative ACL's in the string. The uid/aclbits pair are
1042 * ASCII strings containing the UID/PTS record and and a ascii number
1043 * representing a logical OR of all the ACL permission bits
1047 acl_print(u_char
*s
, u_char
*end
)
1053 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1062 * This wacky order preserves the order used by the "fs" command
1065 #define ACLOUT(acl) \
1066 if (acl & PRSFS_READ) \
1068 if (acl & PRSFS_LOOKUP) \
1070 if (acl & PRSFS_INSERT) \
1072 if (acl & PRSFS_DELETE) \
1074 if (acl & PRSFS_WRITE) \
1076 if (acl & PRSFS_LOCK) \
1078 if (acl & PRSFS_ADMINISTER) \
1081 for (i
= 0; i
< pos
; i
++) {
1082 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1085 printf(" +{%s ", user
);
1092 for (i
= 0; i
< neg
; i
++) {
1093 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1096 printf(" -{%s ", user
);
1107 * Handle calls to the AFS callback service
1111 cb_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 fsint/afscbint.xg
1128 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1130 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1132 bp
+= sizeof(struct rx_header
) + 4;
1135 * Print out the afs call we're invoking. The table used here was
1136 * gleaned from fsint/afscbint.xg
1140 case 204: /* Callback */
1144 j
= EXTRACT_32BITS(bp
);
1145 bp
+= sizeof(int32_t);
1147 for (i
= 0; i
< j
; i
++) {
1156 j
= EXTRACT_32BITS(bp
);
1157 bp
+= sizeof(int32_t);
1162 for (i
= 0; i
< j
; i
++) {
1168 t
= EXTRACT_32BITS(bp
);
1169 bp
+= sizeof(int32_t);
1170 tok2str(cb_types
, "type %d", t
);
1189 * Handle replies to the AFS Callback Service
1193 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1195 struct rx_header
*rxh
;
1197 if (length
<= sizeof(struct rx_header
))
1200 rxh
= (struct rx_header
*) bp
;
1203 * Print out the afs call we're invoking. The table used here was
1204 * gleaned from fsint/afscbint.xg
1207 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1209 bp
+= sizeof(struct rx_header
);
1212 * If it was a data packet, interpret the response.
1215 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1217 case 213: /* InitCallBackState3 */
1225 * Otherwise, just print out the return code
1238 * Handle calls to the AFS protection database server
1242 prot_print(register const u_char
*bp
, int length
)
1248 if (length
<= sizeof(struct rx_header
))
1251 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1256 * Print out the afs call we're invoking. The table used here was
1257 * gleaned from ptserver/ptint.xg
1260 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1264 if (is_ubik(pt_op
)) {
1265 ubik_print(bp
, length
);
1269 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1272 * Decode some of the arguments to the PT calls
1275 bp
+= sizeof(struct rx_header
) + 4;
1278 case 500: /* I New User */
1285 case 501: /* Where is it */
1286 case 506: /* Delete */
1287 case 508: /* Get CPS */
1288 case 512: /* List entry */
1289 case 514: /* List elements */
1290 case 517: /* List owned */
1291 case 518: /* Get CPS2 */
1292 case 519: /* Get host CPS */
1296 case 502: /* Dump entry */
1300 case 503: /* Add to group */
1301 case 507: /* Remove from group */
1302 case 515: /* Is a member of? */
1308 case 504: /* Name to ID */
1312 j
= EXTRACT_32BITS(bp
);
1313 bp
+= sizeof(int32_t);
1316 * Who designed this chicken-shit protocol?
1318 * Each character is stored as a 32-bit
1322 for (i
= 0; i
< j
; i
++) {
1329 case 505: /* Id to name */
1334 i
= EXTRACT_32BITS(bp
);
1335 bp
+= sizeof(int32_t);
1336 for (j
= 0; j
< i
; j
++)
1342 case 509: /* New entry */
1349 case 511: /* Set max */
1355 case 513: /* Change entry */
1364 case 520: /* Update entry */
1381 * Handle replies to the AFS protection service
1385 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1387 struct rx_header
*rxh
;
1391 if (length
< sizeof(struct rx_header
))
1394 rxh
= (struct rx_header
*) bp
;
1397 * Print out the afs call we're invoking. The table used here was
1398 * gleaned from ptserver/ptint.xg. Check to see if it's a
1399 * Ubik call, however.
1404 if (is_ubik(opcode
)) {
1405 ubik_reply_print(bp
, length
, opcode
);
1409 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1411 bp
+= sizeof(struct rx_header
);
1414 * If it was a data packet, interpret the response
1417 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1419 case 504: /* Name to ID */
1424 i
= EXTRACT_32BITS(bp
);
1425 bp
+= sizeof(int32_t);
1426 for (j
= 0; j
< i
; j
++)
1432 case 505: /* ID to name */
1436 j
= EXTRACT_32BITS(bp
);
1437 bp
+= sizeof(int32_t);
1440 * Who designed this chicken-shit protocol?
1442 * Each character is stored as a 32-bit
1446 for (i
= 0; i
< j
; i
++) {
1453 case 508: /* Get CPS */
1454 case 514: /* List elements */
1455 case 517: /* List owned */
1456 case 518: /* Get CPS2 */
1457 case 519: /* Get host CPS */
1461 j
= EXTRACT_32BITS(bp
);
1462 bp
+= sizeof(int32_t);
1463 for (i
= 0; i
< j
; i
++) {
1470 case 510: /* List max */
1481 * Otherwise, just print out the return code
1494 * Handle calls to the AFS volume location database service
1498 vldb_print(register const u_char
*bp
, int length
)
1504 if (length
<= sizeof(struct rx_header
))
1507 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1512 * Print out the afs call we're invoking. The table used here was
1513 * gleaned from vlserver/vldbint.xg
1516 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1520 if (is_ubik(vldb_op
)) {
1521 ubik_print(bp
, length
);
1524 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1527 * Decode some of the arguments to the VLDB calls
1530 bp
+= sizeof(struct rx_header
) + 4;
1533 case 501: /* Create new volume */
1534 case 517: /* Create entry N */
1537 case 502: /* Delete entry */
1538 case 503: /* Get entry by ID */
1539 case 507: /* Update entry */
1540 case 508: /* Set lock */
1541 case 509: /* Release lock */
1542 case 518: /* Get entry by ID N */
1545 TCHECK2(bp
[0], sizeof(int32_t));
1546 i
= EXTRACT_32BITS(bp
);
1547 bp
+= sizeof(int32_t);
1549 printf(" type %s", voltype
[i
]);
1551 case 504: /* Get entry by name */
1552 case 519: /* Get entry by name N */
1553 case 524: /* Update entry by name */
1554 case 527: /* Get entry by name U */
1557 case 505: /* Get new vol id */
1561 case 506: /* Replace entry */
1562 case 520: /* Replace entry N */
1565 TCHECK2(bp
[0], sizeof(int32_t));
1566 i
= EXTRACT_32BITS(bp
);
1567 bp
+= sizeof(int32_t);
1569 printf(" type %s", voltype
[i
]);
1572 case 510: /* List entry */
1573 case 521: /* List entry N */
1588 * Handle replies to the AFS volume location database service
1592 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1594 struct rx_header
*rxh
;
1598 if (length
< sizeof(struct rx_header
))
1601 rxh
= (struct rx_header
*) bp
;
1604 * Print out the afs call we're invoking. The table used here was
1605 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1606 * Ubik call, however.
1611 if (is_ubik(opcode
)) {
1612 ubik_reply_print(bp
, length
, opcode
);
1616 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1618 bp
+= sizeof(struct rx_header
);
1621 * If it was a data packet, interpret the response
1624 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1626 case 510: /* List entry */
1629 printf(" nextindex");
1631 case 503: /* Get entry by id */
1632 case 504: /* Get entry by name */
1633 { unsigned long nservers
, j
;
1635 TCHECK2(bp
[0], sizeof(int32_t));
1636 bp
+= sizeof(int32_t);
1637 printf(" numservers");
1638 TCHECK2(bp
[0], sizeof(int32_t));
1639 nservers
= EXTRACT_32BITS(bp
);
1640 bp
+= sizeof(int32_t);
1641 printf(" %lu", nservers
);
1643 for (i
= 0; i
< 8; i
++) {
1644 TCHECK2(bp
[0], sizeof(int32_t));
1647 inet_ntoa(*((struct in_addr
*) bp
)));
1648 bp
+= sizeof(int32_t);
1650 printf(" partitions");
1651 for (i
= 0; i
< 8; i
++) {
1652 TCHECK2(bp
[0], sizeof(int32_t));
1653 j
= EXTRACT_32BITS(bp
);
1654 if (i
< nservers
&& j
<= 26)
1655 printf(" %c", 'a' + (int)j
);
1656 else if (i
< nservers
)
1658 bp
+= sizeof(int32_t);
1660 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1661 bp
+= 8 * sizeof(int32_t);
1670 case 505: /* Get new volume ID */
1674 case 521: /* List entry */
1675 case 529: /* List entry U */
1678 printf(" nextindex");
1680 case 518: /* Get entry by ID N */
1681 case 519: /* Get entry by name N */
1682 { unsigned long nservers
, j
;
1684 printf(" numservers");
1685 TCHECK2(bp
[0], sizeof(int32_t));
1686 nservers
= EXTRACT_32BITS(bp
);
1687 bp
+= sizeof(int32_t);
1688 printf(" %lu", nservers
);
1690 for (i
= 0; i
< 13; i
++) {
1691 TCHECK2(bp
[0], sizeof(int32_t));
1694 inet_ntoa(*((struct in_addr
*) bp
)));
1695 bp
+= sizeof(int32_t);
1697 printf(" partitions");
1698 for (i
= 0; i
< 13; i
++) {
1699 TCHECK2(bp
[0], sizeof(int32_t));
1700 j
= EXTRACT_32BITS(bp
);
1701 if (i
< nservers
&& j
<= 26)
1702 printf(" %c", 'a' + (int)j
);
1703 else if (i
< nservers
)
1705 bp
+= sizeof(int32_t);
1707 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1708 bp
+= 13 * sizeof(int32_t);
1717 case 526: /* Get entry by ID U */
1718 case 527: /* Get entry by name U */
1719 { unsigned long nservers
, j
;
1721 printf(" numservers");
1722 TCHECK2(bp
[0], sizeof(int32_t));
1723 nservers
= EXTRACT_32BITS(bp
);
1724 bp
+= sizeof(int32_t);
1725 printf(" %lu", nservers
);
1727 for (i
= 0; i
< 13; i
++) {
1736 TCHECK2(bp
[0], 4 * 13);
1738 printf(" partitions");
1739 for (i
= 0; i
< 13; i
++) {
1740 TCHECK2(bp
[0], sizeof(int32_t));
1741 j
= EXTRACT_32BITS(bp
);
1742 if (i
< nservers
&& j
<= 26)
1743 printf(" %c", 'a' + (int)j
);
1744 else if (i
< nservers
)
1746 bp
+= sizeof(int32_t);
1748 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1749 bp
+= 13 * sizeof(int32_t);
1763 * Otherwise, just print out the return code
1776 * Handle calls to the AFS Kerberos Authentication service
1780 kauth_print(register const u_char
*bp
, int length
)
1785 if (length
<= sizeof(struct rx_header
))
1788 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1793 * Print out the afs call we're invoking. The table used here was
1794 * gleaned from kauth/kauth.rg
1797 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1801 if (is_ubik(kauth_op
)) {
1802 ubik_print(bp
, length
);
1807 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1810 * Decode some of the arguments to the KA calls
1813 bp
+= sizeof(struct rx_header
) + 4;
1816 case 1: /* Authenticate old */;
1817 case 21: /* Authenticate */
1818 case 22: /* Authenticate-V2 */
1819 case 2: /* Change PW */
1820 case 5: /* Set fields */
1821 case 6: /* Create user */
1822 case 7: /* Delete user */
1823 case 8: /* Get entry */
1824 case 14: /* Unlock */
1825 case 15: /* Lock status */
1826 printf(" principal");
1830 case 3: /* GetTicket-old */
1831 case 23: /* GetTicket */
1838 TCHECK2(bp
[0], sizeof(int32_t));
1839 i
= (int) EXTRACT_32BITS(bp
);
1840 bp
+= sizeof(int32_t);
1843 printf(" principal");
1848 case 4: /* Set Password */
1849 printf(" principal");
1855 case 12: /* Get password */
1866 printf(" [|kauth]");
1870 * Handle replies to the AFS Kerberos Authentication Service
1874 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1876 struct rx_header
*rxh
;
1878 if (length
<= sizeof(struct rx_header
))
1881 rxh
= (struct rx_header
*) bp
;
1884 * Print out the afs call we're invoking. The table used here was
1885 * gleaned from kauth/kauth.rg
1890 if (is_ubik(opcode
)) {
1891 ubik_reply_print(bp
, length
, opcode
);
1895 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1897 bp
+= sizeof(struct rx_header
);
1900 * If it was a data packet, interpret the response.
1903 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1904 /* Well, no, not really. Leave this for later */
1908 * Otherwise, just print out the return code
1917 printf(" [|kauth]");
1921 * Handle calls to the AFS Volume location service
1925 vol_print(register const u_char
*bp
, int length
)
1929 if (length
<= sizeof(struct rx_header
))
1932 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1937 * Print out the afs call we're invoking. The table used here was
1938 * gleaned from volser/volint.xg
1941 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1943 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1946 * Normally there would be a switch statement here to decode the
1947 * arguments to the AFS call, but since I don't have access to
1948 * an AFS server (yet) and I'm not an AFS admin, I can't
1949 * test any of these calls. Leave this blank for now.
1959 * Handle replies to the AFS Volume Service
1963 vol_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(" vol reply %s", tok2str(vol_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 * Handle calls to the AFS BOS service
2007 bos_print(register const u_char
*bp
, int length
)
2012 if (length
<= sizeof(struct rx_header
))
2015 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
2020 * Print out the afs call we're invoking. The table used here was
2021 * gleaned from bozo/bosint.xg
2024 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2026 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2029 * Decode some of the arguments to the BOS calls
2032 bp
+= sizeof(struct rx_header
) + 4;
2035 case 80: /* Create B node */
2038 printf(" instance");
2041 case 81: /* Delete B node */
2042 case 83: /* Get status */
2043 case 85: /* Get instance info */
2044 case 87: /* Add super user */
2045 case 88: /* Delete super user */
2046 case 93: /* Set cell name */
2047 case 96: /* Add cell host */
2048 case 97: /* Delete cell host */
2049 case 104: /* Restart */
2050 case 106: /* Uninstall */
2051 case 108: /* Exec */
2052 case 112: /* Getlog */
2053 case 114: /* Get instance strings */
2056 case 82: /* Set status */
2057 case 98: /* Set T status */
2062 case 86: /* Get instance parm */
2067 case 84: /* Enumerate instance */
2068 case 89: /* List super users */
2069 case 90: /* List keys */
2070 case 91: /* Add key */
2071 case 92: /* Delete key */
2072 case 95: /* Get cell host */
2075 case 105: /* Install */
2095 * Handle replies to the AFS BOS Service
2099 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2101 struct rx_header
*rxh
;
2103 if (length
<= sizeof(struct rx_header
))
2106 rxh
= (struct rx_header
*) bp
;
2109 * Print out the afs call we're invoking. The table used here was
2110 * gleaned from volser/volint.xg
2113 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2115 bp
+= sizeof(struct rx_header
);
2118 * If it was a data packet, interpret the response.
2121 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2122 /* Well, no, not really. Leave this for later */
2126 * Otherwise, just print out the return code
2139 * Check to see if this is a Ubik opcode.
2143 is_ubik(u_int32_t opcode
)
2145 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2146 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2153 * Handle Ubik opcodes to any one of the replicated database services
2157 ubik_print(register const u_char
*bp
, int length
)
2163 * Print out the afs call we're invoking. The table used here was
2164 * gleaned from ubik/ubik_int.xg
2167 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2169 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2172 * Decode some of the arguments to the Ubik calls
2175 bp
+= sizeof(struct rx_header
) + 4;
2178 case 10000: /* Beacon */
2180 temp
= EXTRACT_32BITS(bp
);
2181 bp
+= sizeof(int32_t);
2182 printf(" syncsite %s", temp
? "yes" : "no");
2183 printf(" votestart");
2185 printf(" dbversion");
2190 case 10003: /* Get sync site */
2194 case 20000: /* Begin */
2195 case 20001: /* Commit */
2196 case 20007: /* Abort */
2197 case 20008: /* Release locks */
2198 case 20010: /* Writev */
2202 case 20002: /* Lock */
2211 temp
= EXTRACT_32BITS(bp
);
2212 bp
+= sizeof(int32_t);
2213 tok2str(ubik_lock_types
, "type %d", temp
);
2215 case 20003: /* Write */
2223 case 20005: /* Get file */
2227 case 20006: /* Send file */
2232 printf(" dbversion");
2235 case 20009: /* Truncate */
2243 case 20012: /* Set version */
2246 printf(" oldversion");
2248 printf(" newversion");
2262 * Handle Ubik replies to any one of the replicated database services
2266 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2268 struct rx_header
*rxh
;
2270 if (length
< sizeof(struct rx_header
))
2273 rxh
= (struct rx_header
*) bp
;
2276 * Print out the ubik call we're invoking. This table was gleaned
2277 * from ubik/ubik_int.xg
2280 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2282 bp
+= sizeof(struct rx_header
);
2285 * If it was a data packet, print out the arguments to the Ubik calls
2288 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2290 case 10000: /* Beacon */
2293 case 20004: /* Get version */
2294 printf(" dbversion");
2302 * Otherwise, print out "yes" it it was a beacon packet (because
2303 * that's how yes votes are returned, go figure), otherwise
2304 * just print out the error code.
2309 case 10000: /* Beacon */
2310 printf(" vote yes until");
2325 * Handle RX ACK packets.
2329 rx_ack_print(register const u_char
*bp
, int length
)
2331 struct rx_ackPacket
*rxa
;
2334 if (length
< sizeof(struct rx_header
))
2337 bp
+= sizeof(struct rx_header
);
2340 * This may seem a little odd .... the rx_ackPacket structure
2341 * contains an array of individual packet acknowledgements
2342 * (used for selective ack/nack), but since it's variable in size,
2343 * we don't want to truncate based on the size of the whole
2344 * rx_ackPacket structure.
2347 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2349 rxa
= (struct rx_ackPacket
*) bp
;
2350 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2353 * Print out a few useful things from the ack packet structure
2357 printf(" bufspace %d maxskew %d",
2358 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2359 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2361 printf(" first %d serial %d reason %s",
2362 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2363 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2366 * Okay, now we print out the ack array. The way _this_ works
2367 * is that we start at "first", and step through the ack array.
2368 * If we have a contiguous range of acks/nacks, try to
2369 * collapse them into a range.
2371 * If you're really clever, you might have noticed that this
2372 * doesn't seem quite correct. Specifically, due to structure
2373 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2374 * yield the start of the ack array (because RX_MAXACKS is 255
2375 * and the structure will likely get padded to a 2 or 4 byte
2376 * boundary). However, this is the way it's implemented inside
2377 * of AFS - the start of the extra fields are at
2378 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2379 * the exact start of the ack array. Sigh. That's why we aren't
2380 * using bp, but instead use rxa->acks[]. But nAcks gets added
2381 * to bp after this, so bp ends up at the right spot. Go figure.
2384 if (rxa
->nAcks
!= 0) {
2386 TCHECK2(bp
[0], rxa
->nAcks
);
2389 * Sigh, this is gross, but it seems to work to collapse
2393 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2394 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2397 * I figured this deserved _some_ explanation.
2398 * First, print "acked" and the packet seq
2399 * number if this is the first time we've
2400 * seen an acked packet.
2405 rxa
->firstPacket
+ i
);
2410 * Otherwise, if the there is a skip in
2411 * the range (such as an nacked packet in
2412 * the middle of some acked packets),
2413 * then print the current packet number
2414 * seperated from the last number by
2418 else if (last
!= i
- 1) {
2419 printf(",%d", rxa
->firstPacket
+ i
);
2424 * We always set last to the value of
2425 * the last ack we saw. Conversely, start
2426 * is set to the value of the first ack
2427 * we saw in a range.
2433 * Okay, this bit a code gets executed when
2434 * we hit a nack ... in _this_ case we
2435 * want to print out the range of packets
2436 * that were acked, so we need to print
2437 * the _previous_ packet number seperated
2438 * from the first by a dash (-). Since we
2439 * already printed the first packet above,
2440 * just print the final packet. Don't
2441 * do this if there will be a single-length
2444 } else if (last
== i
- 1 && start
!= last
)
2445 printf("-%d", rxa
->firstPacket
+ i
- 1);
2448 * So, what's going on here? We ran off the end of the
2449 * ack list, and if we got a range we need to finish it up.
2450 * So we need to determine if the last packet in the list
2451 * was an ack (if so, then last will be set to it) and
2452 * we need to see if the last range didn't start with the
2453 * last packet (because if it _did_, then that would mean
2454 * that the packet number has already been printed and
2455 * we don't need to print it again).
2458 if (last
== i
- 1 && start
!= last
)
2459 printf("-%d", rxa
->firstPacket
+ i
- 1);
2462 * Same as above, just without comments
2465 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2466 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2468 printf(" nacked %d",
2469 rxa
->firstPacket
+ i
);
2471 } else if (last
!= i
- 1) {
2472 printf(",%d", rxa
->firstPacket
+ i
);
2476 } else if (last
== i
- 1 && start
!= last
)
2477 printf("-%d", rxa
->firstPacket
+ i
- 1);
2479 if (last
== i
- 1 && start
!= last
)
2480 printf("-%d", rxa
->firstPacket
+ i
- 1);
2487 * These are optional fields; depending on your version of AFS,
2488 * you may or may not see them
2491 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2507 printf(" maxpackets");