]>
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.19 2000-10-05 04:10:04 itojun Exp $";
27 #include <sys/param.h>
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <netinet/in.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
*, int, 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
, sizeof(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
, sizeof(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
, int maxsize
, u_char
*end
)
1053 if ((user
= (char *)malloc(maxsize
)) == NULL
)
1056 if (sscanf((char *) s
, "%d %d\n%n", &pos
, &neg
, &n
) != 2)
1065 * This wacky order preserves the order used by the "fs" command
1068 #define ACLOUT(acl) \
1069 if (acl & PRSFS_READ) \
1071 if (acl & PRSFS_LOOKUP) \
1073 if (acl & PRSFS_INSERT) \
1075 if (acl & PRSFS_DELETE) \
1077 if (acl & PRSFS_WRITE) \
1079 if (acl & PRSFS_LOCK) \
1081 if (acl & PRSFS_ADMINISTER) \
1084 for (i
= 0; i
< pos
; i
++) {
1085 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1088 printf(" +{%s ", user
);
1095 for (i
= 0; i
< neg
; i
++) {
1096 if (sscanf((char *) s
, "%s %d\n%n", user
, &acl
, &n
) != 2)
1099 printf(" -{%s ", user
);
1114 * Handle calls to the AFS callback service
1118 cb_print(register const u_char
*bp
, int length
)
1123 if (length
<= sizeof(struct rx_header
))
1126 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1131 * Print out the afs call we're invoking. The table used here was
1132 * gleaned from fsint/afscbint.xg
1135 cb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1137 printf(" cb call %s", tok2str(cb_req
, "op#%d", cb_op
));
1139 bp
+= sizeof(struct rx_header
) + 4;
1142 * Print out the afs call we're invoking. The table used here was
1143 * gleaned from fsint/afscbint.xg
1147 case 204: /* Callback */
1151 j
= EXTRACT_32BITS(bp
);
1152 bp
+= sizeof(int32_t);
1154 for (i
= 0; i
< j
; i
++) {
1163 j
= EXTRACT_32BITS(bp
);
1164 bp
+= sizeof(int32_t);
1169 for (i
= 0; i
< j
; i
++) {
1175 t
= EXTRACT_32BITS(bp
);
1176 bp
+= sizeof(int32_t);
1177 tok2str(cb_types
, "type %d", t
);
1196 * Handle replies to the AFS Callback Service
1200 cb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1202 struct rx_header
*rxh
;
1204 if (length
<= sizeof(struct rx_header
))
1207 rxh
= (struct rx_header
*) bp
;
1210 * Print out the afs call we're invoking. The table used here was
1211 * gleaned from fsint/afscbint.xg
1214 printf(" cb reply %s", tok2str(cb_req
, "op#%d", opcode
));
1216 bp
+= sizeof(struct rx_header
);
1219 * If it was a data packet, interpret the response.
1222 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1224 case 213: /* InitCallBackState3 */
1232 * Otherwise, just print out the return code
1245 * Handle calls to the AFS protection database server
1249 prot_print(register const u_char
*bp
, int length
)
1255 if (length
<= sizeof(struct rx_header
))
1258 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1263 * Print out the afs call we're invoking. The table used here was
1264 * gleaned from ptserver/ptint.xg
1267 pt_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1271 if (is_ubik(pt_op
)) {
1272 ubik_print(bp
, length
);
1276 printf(" call %s", tok2str(pt_req
, "op#%d", pt_op
));
1279 * Decode some of the arguments to the PT calls
1282 bp
+= sizeof(struct rx_header
) + 4;
1285 case 500: /* I New User */
1292 case 501: /* Where is it */
1293 case 506: /* Delete */
1294 case 508: /* Get CPS */
1295 case 512: /* List entry */
1296 case 514: /* List elements */
1297 case 517: /* List owned */
1298 case 518: /* Get CPS2 */
1299 case 519: /* Get host CPS */
1303 case 502: /* Dump entry */
1307 case 503: /* Add to group */
1308 case 507: /* Remove from group */
1309 case 515: /* Is a member of? */
1315 case 504: /* Name to ID */
1319 j
= EXTRACT_32BITS(bp
);
1320 bp
+= sizeof(int32_t);
1323 * Who designed this chicken-shit protocol?
1325 * Each character is stored as a 32-bit
1329 for (i
= 0; i
< j
; i
++) {
1336 case 505: /* Id to name */
1341 i
= EXTRACT_32BITS(bp
);
1342 bp
+= sizeof(int32_t);
1343 for (j
= 0; j
< i
; j
++)
1349 case 509: /* New entry */
1356 case 511: /* Set max */
1362 case 513: /* Change entry */
1371 case 520: /* Update entry */
1388 * Handle replies to the AFS protection service
1392 prot_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1394 struct rx_header
*rxh
;
1398 if (length
< sizeof(struct rx_header
))
1401 rxh
= (struct rx_header
*) bp
;
1404 * Print out the afs call we're invoking. The table used here was
1405 * gleaned from ptserver/ptint.xg. Check to see if it's a
1406 * Ubik call, however.
1411 if (is_ubik(opcode
)) {
1412 ubik_reply_print(bp
, length
, opcode
);
1416 printf(" reply %s", tok2str(pt_req
, "op#%d", opcode
));
1418 bp
+= sizeof(struct rx_header
);
1421 * If it was a data packet, interpret the response
1424 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1426 case 504: /* Name to ID */
1431 i
= EXTRACT_32BITS(bp
);
1432 bp
+= sizeof(int32_t);
1433 for (j
= 0; j
< i
; j
++)
1439 case 505: /* ID to name */
1443 j
= EXTRACT_32BITS(bp
);
1444 bp
+= sizeof(int32_t);
1447 * Who designed this chicken-shit protocol?
1449 * Each character is stored as a 32-bit
1453 for (i
= 0; i
< j
; i
++) {
1460 case 508: /* Get CPS */
1461 case 514: /* List elements */
1462 case 517: /* List owned */
1463 case 518: /* Get CPS2 */
1464 case 519: /* Get host CPS */
1468 j
= EXTRACT_32BITS(bp
);
1469 bp
+= sizeof(int32_t);
1470 for (i
= 0; i
< j
; i
++) {
1477 case 510: /* List max */
1488 * Otherwise, just print out the return code
1501 * Handle calls to the AFS volume location database service
1505 vldb_print(register const u_char
*bp
, int length
)
1511 if (length
<= sizeof(struct rx_header
))
1514 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1519 * Print out the afs call we're invoking. The table used here was
1520 * gleaned from vlserver/vldbint.xg
1523 vldb_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1527 if (is_ubik(vldb_op
)) {
1528 ubik_print(bp
, length
);
1531 printf(" call %s", tok2str(vldb_req
, "op#%d", vldb_op
));
1534 * Decode some of the arguments to the VLDB calls
1537 bp
+= sizeof(struct rx_header
) + 4;
1540 case 501: /* Create new volume */
1541 case 517: /* Create entry N */
1544 case 502: /* Delete entry */
1545 case 503: /* Get entry by ID */
1546 case 507: /* Update entry */
1547 case 508: /* Set lock */
1548 case 509: /* Release lock */
1549 case 518: /* Get entry by ID N */
1552 TCHECK2(bp
[0], sizeof(int32_t));
1553 i
= EXTRACT_32BITS(bp
);
1554 bp
+= sizeof(int32_t);
1556 printf(" type %s", voltype
[i
]);
1558 case 504: /* Get entry by name */
1559 case 519: /* Get entry by name N */
1560 case 524: /* Update entry by name */
1561 case 527: /* Get entry by name U */
1564 case 505: /* Get new vol id */
1568 case 506: /* Replace entry */
1569 case 520: /* Replace entry N */
1572 TCHECK2(bp
[0], sizeof(int32_t));
1573 i
= EXTRACT_32BITS(bp
);
1574 bp
+= sizeof(int32_t);
1576 printf(" type %s", voltype
[i
]);
1579 case 510: /* List entry */
1580 case 521: /* List entry N */
1595 * Handle replies to the AFS volume location database service
1599 vldb_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1601 struct rx_header
*rxh
;
1605 if (length
< sizeof(struct rx_header
))
1608 rxh
= (struct rx_header
*) bp
;
1611 * Print out the afs call we're invoking. The table used here was
1612 * gleaned from vlserver/vldbint.xg. Check to see if it's a
1613 * Ubik call, however.
1618 if (is_ubik(opcode
)) {
1619 ubik_reply_print(bp
, length
, opcode
);
1623 printf(" reply %s", tok2str(vldb_req
, "op#%d", opcode
));
1625 bp
+= sizeof(struct rx_header
);
1628 * If it was a data packet, interpret the response
1631 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1633 case 510: /* List entry */
1636 printf(" nextindex");
1638 case 503: /* Get entry by id */
1639 case 504: /* Get entry by name */
1640 { unsigned long nservers
, j
;
1642 TCHECK2(bp
[0], sizeof(int32_t));
1643 bp
+= sizeof(int32_t);
1644 printf(" numservers");
1645 TCHECK2(bp
[0], sizeof(int32_t));
1646 nservers
= EXTRACT_32BITS(bp
);
1647 bp
+= sizeof(int32_t);
1648 printf(" %lu", nservers
);
1650 for (i
= 0; i
< 8; i
++) {
1651 TCHECK2(bp
[0], sizeof(int32_t));
1654 inet_ntoa(*((struct in_addr
*) bp
)));
1655 bp
+= sizeof(int32_t);
1657 printf(" partitions");
1658 for (i
= 0; i
< 8; i
++) {
1659 TCHECK2(bp
[0], sizeof(int32_t));
1660 j
= EXTRACT_32BITS(bp
);
1661 if (i
< nservers
&& j
<= 26)
1662 printf(" %c", 'a' + (int)j
);
1663 else if (i
< nservers
)
1665 bp
+= sizeof(int32_t);
1667 TCHECK2(bp
[0], 8 * sizeof(int32_t));
1668 bp
+= 8 * sizeof(int32_t);
1677 case 505: /* Get new volume ID */
1681 case 521: /* List entry */
1682 case 529: /* List entry U */
1685 printf(" nextindex");
1687 case 518: /* Get entry by ID N */
1688 case 519: /* Get entry by name N */
1689 { unsigned long nservers
, j
;
1691 printf(" numservers");
1692 TCHECK2(bp
[0], sizeof(int32_t));
1693 nservers
= EXTRACT_32BITS(bp
);
1694 bp
+= sizeof(int32_t);
1695 printf(" %lu", nservers
);
1697 for (i
= 0; i
< 13; i
++) {
1698 TCHECK2(bp
[0], sizeof(int32_t));
1701 inet_ntoa(*((struct in_addr
*) bp
)));
1702 bp
+= sizeof(int32_t);
1704 printf(" partitions");
1705 for (i
= 0; i
< 13; i
++) {
1706 TCHECK2(bp
[0], sizeof(int32_t));
1707 j
= EXTRACT_32BITS(bp
);
1708 if (i
< nservers
&& j
<= 26)
1709 printf(" %c", 'a' + (int)j
);
1710 else if (i
< nservers
)
1712 bp
+= sizeof(int32_t);
1714 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1715 bp
+= 13 * sizeof(int32_t);
1724 case 526: /* Get entry by ID U */
1725 case 527: /* Get entry by name U */
1726 { unsigned long nservers
, j
;
1728 printf(" numservers");
1729 TCHECK2(bp
[0], sizeof(int32_t));
1730 nservers
= EXTRACT_32BITS(bp
);
1731 bp
+= sizeof(int32_t);
1732 printf(" %lu", nservers
);
1734 for (i
= 0; i
< 13; i
++) {
1743 TCHECK2(bp
[0], 4 * 13);
1745 printf(" partitions");
1746 for (i
= 0; i
< 13; i
++) {
1747 TCHECK2(bp
[0], sizeof(int32_t));
1748 j
= EXTRACT_32BITS(bp
);
1749 if (i
< nservers
&& j
<= 26)
1750 printf(" %c", 'a' + (int)j
);
1751 else if (i
< nservers
)
1753 bp
+= sizeof(int32_t);
1755 TCHECK2(bp
[0], 13 * sizeof(int32_t));
1756 bp
+= 13 * sizeof(int32_t);
1770 * Otherwise, just print out the return code
1783 * Handle calls to the AFS Kerberos Authentication service
1787 kauth_print(register const u_char
*bp
, int length
)
1792 if (length
<= sizeof(struct rx_header
))
1795 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1800 * Print out the afs call we're invoking. The table used here was
1801 * gleaned from kauth/kauth.rg
1804 kauth_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1808 if (is_ubik(kauth_op
)) {
1809 ubik_print(bp
, length
);
1814 printf(" call %s", tok2str(kauth_req
, "op#%d", kauth_op
));
1817 * Decode some of the arguments to the KA calls
1820 bp
+= sizeof(struct rx_header
) + 4;
1823 case 1: /* Authenticate old */;
1824 case 21: /* Authenticate */
1825 case 22: /* Authenticate-V2 */
1826 case 2: /* Change PW */
1827 case 5: /* Set fields */
1828 case 6: /* Create user */
1829 case 7: /* Delete user */
1830 case 8: /* Get entry */
1831 case 14: /* Unlock */
1832 case 15: /* Lock status */
1833 printf(" principal");
1837 case 3: /* GetTicket-old */
1838 case 23: /* GetTicket */
1845 TCHECK2(bp
[0], sizeof(int32_t));
1846 i
= (int) EXTRACT_32BITS(bp
);
1847 bp
+= sizeof(int32_t);
1850 printf(" principal");
1855 case 4: /* Set Password */
1856 printf(" principal");
1862 case 12: /* Get password */
1873 printf(" [|kauth]");
1877 * Handle replies to the AFS Kerberos Authentication Service
1881 kauth_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1883 struct rx_header
*rxh
;
1885 if (length
<= sizeof(struct rx_header
))
1888 rxh
= (struct rx_header
*) bp
;
1891 * Print out the afs call we're invoking. The table used here was
1892 * gleaned from kauth/kauth.rg
1897 if (is_ubik(opcode
)) {
1898 ubik_reply_print(bp
, length
, opcode
);
1902 printf(" reply %s", tok2str(kauth_req
, "op#%d", opcode
));
1904 bp
+= sizeof(struct rx_header
);
1907 * If it was a data packet, interpret the response.
1910 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1911 /* Well, no, not really. Leave this for later */
1915 * Otherwise, just print out the return code
1924 printf(" [|kauth]");
1928 * Handle calls to the AFS Volume location service
1932 vol_print(register const u_char
*bp
, int length
)
1936 if (length
<= sizeof(struct rx_header
))
1939 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
1944 * Print out the afs call we're invoking. The table used here was
1945 * gleaned from volser/volint.xg
1948 vol_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
1950 printf(" vol call %s", tok2str(vol_req
, "op#%d", vol_op
));
1953 * Normally there would be a switch statement here to decode the
1954 * arguments to the AFS call, but since I don't have access to
1955 * an AFS server (yet) and I'm not an AFS admin, I can't
1956 * test any of these calls. Leave this blank for now.
1966 * Handle replies to the AFS Volume Service
1970 vol_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
1972 struct rx_header
*rxh
;
1974 if (length
<= sizeof(struct rx_header
))
1977 rxh
= (struct rx_header
*) bp
;
1980 * Print out the afs call we're invoking. The table used here was
1981 * gleaned from volser/volint.xg
1984 printf(" vol reply %s", tok2str(vol_req
, "op#%d", opcode
));
1986 bp
+= sizeof(struct rx_header
);
1989 * If it was a data packet, interpret the response.
1992 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
1993 /* Well, no, not really. Leave this for later */
1997 * Otherwise, just print out the return code
2010 * Handle calls to the AFS BOS service
2014 bos_print(register const u_char
*bp
, int length
)
2019 if (length
<= sizeof(struct rx_header
))
2022 if (snapend
- bp
+ 1 <= sizeof(struct rx_header
) + sizeof(int32_t)) {
2027 * Print out the afs call we're invoking. The table used here was
2028 * gleaned from bozo/bosint.xg
2031 bos_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2033 printf(" bos call %s", tok2str(bos_req
, "op#%d", bos_op
));
2036 * Decode some of the arguments to the BOS calls
2039 bp
+= sizeof(struct rx_header
) + 4;
2042 case 80: /* Create B node */
2045 printf(" instance");
2048 case 81: /* Delete B node */
2049 case 83: /* Get status */
2050 case 85: /* Get instance info */
2051 case 87: /* Add super user */
2052 case 88: /* Delete super user */
2053 case 93: /* Set cell name */
2054 case 96: /* Add cell host */
2055 case 97: /* Delete cell host */
2056 case 104: /* Restart */
2057 case 106: /* Uninstall */
2058 case 108: /* Exec */
2059 case 112: /* Getlog */
2060 case 114: /* Get instance strings */
2063 case 82: /* Set status */
2064 case 98: /* Set T status */
2069 case 86: /* Get instance parm */
2074 case 84: /* Enumerate instance */
2075 case 89: /* List super users */
2076 case 90: /* List keys */
2077 case 91: /* Add key */
2078 case 92: /* Delete key */
2079 case 95: /* Get cell host */
2082 case 105: /* Install */
2102 * Handle replies to the AFS BOS Service
2106 bos_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2108 struct rx_header
*rxh
;
2110 if (length
<= sizeof(struct rx_header
))
2113 rxh
= (struct rx_header
*) bp
;
2116 * Print out the afs call we're invoking. The table used here was
2117 * gleaned from volser/volint.xg
2120 printf(" bos reply %s", tok2str(bos_req
, "op#%d", opcode
));
2122 bp
+= sizeof(struct rx_header
);
2125 * If it was a data packet, interpret the response.
2128 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2129 /* Well, no, not really. Leave this for later */
2133 * Otherwise, just print out the return code
2146 * Check to see if this is a Ubik opcode.
2150 is_ubik(u_int32_t opcode
)
2152 if ((opcode
>= VOTE_LOW
&& opcode
<= VOTE_HIGH
) ||
2153 (opcode
>= DISK_LOW
&& opcode
<= DISK_HIGH
))
2160 * Handle Ubik opcodes to any one of the replicated database services
2164 ubik_print(register const u_char
*bp
, int length
)
2170 * Print out the afs call we're invoking. The table used here was
2171 * gleaned from ubik/ubik_int.xg
2174 ubik_op
= EXTRACT_32BITS(bp
+ sizeof(struct rx_header
));
2176 printf(" ubik call %s", tok2str(ubik_req
, "op#%d", ubik_op
));
2179 * Decode some of the arguments to the Ubik calls
2182 bp
+= sizeof(struct rx_header
) + 4;
2185 case 10000: /* Beacon */
2187 temp
= EXTRACT_32BITS(bp
);
2188 bp
+= sizeof(int32_t);
2189 printf(" syncsite %s", temp
? "yes" : "no");
2190 printf(" votestart");
2192 printf(" dbversion");
2197 case 10003: /* Get sync site */
2201 case 20000: /* Begin */
2202 case 20001: /* Commit */
2203 case 20007: /* Abort */
2204 case 20008: /* Release locks */
2205 case 20010: /* Writev */
2209 case 20002: /* Lock */
2218 temp
= EXTRACT_32BITS(bp
);
2219 bp
+= sizeof(int32_t);
2220 tok2str(ubik_lock_types
, "type %d", temp
);
2222 case 20003: /* Write */
2230 case 20005: /* Get file */
2234 case 20006: /* Send file */
2239 printf(" dbversion");
2242 case 20009: /* Truncate */
2250 case 20012: /* Set version */
2253 printf(" oldversion");
2255 printf(" newversion");
2269 * Handle Ubik replies to any one of the replicated database services
2273 ubik_reply_print(register const u_char
*bp
, int length
, int32_t opcode
)
2275 struct rx_header
*rxh
;
2277 if (length
< sizeof(struct rx_header
))
2280 rxh
= (struct rx_header
*) bp
;
2283 * Print out the ubik call we're invoking. This table was gleaned
2284 * from ubik/ubik_int.xg
2287 printf(" ubik reply %s", tok2str(ubik_req
, "op#%d", opcode
));
2289 bp
+= sizeof(struct rx_header
);
2292 * If it was a data packet, print out the arguments to the Ubik calls
2295 if (rxh
->type
== RX_PACKET_TYPE_DATA
)
2297 case 10000: /* Beacon */
2300 case 20004: /* Get version */
2301 printf(" dbversion");
2309 * Otherwise, print out "yes" it it was a beacon packet (because
2310 * that's how yes votes are returned, go figure), otherwise
2311 * just print out the error code.
2316 case 10000: /* Beacon */
2317 printf(" vote yes until");
2332 * Handle RX ACK packets.
2336 rx_ack_print(register const u_char
*bp
, int length
)
2338 struct rx_ackPacket
*rxa
;
2341 if (length
< sizeof(struct rx_header
))
2344 bp
+= sizeof(struct rx_header
);
2347 * This may seem a little odd .... the rx_ackPacket structure
2348 * contains an array of individual packet acknowledgements
2349 * (used for selective ack/nack), but since it's variable in size,
2350 * we don't want to truncate based on the size of the whole
2351 * rx_ackPacket structure.
2354 TCHECK2(bp
[0], sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2356 rxa
= (struct rx_ackPacket
*) bp
;
2357 bp
+= (sizeof(struct rx_ackPacket
) - RX_MAXACKS
);
2360 * Print out a few useful things from the ack packet structure
2364 printf(" bufspace %d maxskew %d",
2365 (int) EXTRACT_16BITS(&rxa
->bufferSpace
),
2366 (int) EXTRACT_16BITS(&rxa
->maxSkew
));
2368 printf(" first %d serial %d reason %s",
2369 EXTRACT_32BITS(&rxa
->firstPacket
), EXTRACT_32BITS(&rxa
->serial
),
2370 tok2str(rx_ack_reasons
, "#%d", (int) rxa
->reason
));
2373 * Okay, now we print out the ack array. The way _this_ works
2374 * is that we start at "first", and step through the ack array.
2375 * If we have a contiguous range of acks/nacks, try to
2376 * collapse them into a range.
2378 * If you're really clever, you might have noticed that this
2379 * doesn't seem quite correct. Specifically, due to structure
2380 * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually
2381 * yield the start of the ack array (because RX_MAXACKS is 255
2382 * and the structure will likely get padded to a 2 or 4 byte
2383 * boundary). However, this is the way it's implemented inside
2384 * of AFS - the start of the extra fields are at
2385 * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_
2386 * the exact start of the ack array. Sigh. That's why we aren't
2387 * using bp, but instead use rxa->acks[]. But nAcks gets added
2388 * to bp after this, so bp ends up at the right spot. Go figure.
2391 if (rxa
->nAcks
!= 0) {
2393 TCHECK2(bp
[0], rxa
->nAcks
);
2396 * Sigh, this is gross, but it seems to work to collapse
2400 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2401 if (rxa
->acks
[i
] == RX_ACK_TYPE_ACK
) {
2404 * I figured this deserved _some_ explanation.
2405 * First, print "acked" and the packet seq
2406 * number if this is the first time we've
2407 * seen an acked packet.
2412 rxa
->firstPacket
+ i
);
2417 * Otherwise, if the there is a skip in
2418 * the range (such as an nacked packet in
2419 * the middle of some acked packets),
2420 * then print the current packet number
2421 * seperated from the last number by
2425 else if (last
!= i
- 1) {
2426 printf(",%d", rxa
->firstPacket
+ i
);
2431 * We always set last to the value of
2432 * the last ack we saw. Conversely, start
2433 * is set to the value of the first ack
2434 * we saw in a range.
2440 * Okay, this bit a code gets executed when
2441 * we hit a nack ... in _this_ case we
2442 * want to print out the range of packets
2443 * that were acked, so we need to print
2444 * the _previous_ packet number seperated
2445 * from the first by a dash (-). Since we
2446 * already printed the first packet above,
2447 * just print the final packet. Don't
2448 * do this if there will be a single-length
2451 } else if (last
== i
- 1 && start
!= last
)
2452 printf("-%d", rxa
->firstPacket
+ i
- 1);
2455 * So, what's going on here? We ran off the end of the
2456 * ack list, and if we got a range we need to finish it up.
2457 * So we need to determine if the last packet in the list
2458 * was an ack (if so, then last will be set to it) and
2459 * we need to see if the last range didn't start with the
2460 * last packet (because if it _did_, then that would mean
2461 * that the packet number has already been printed and
2462 * we don't need to print it again).
2465 if (last
== i
- 1 && start
!= last
)
2466 printf("-%d", rxa
->firstPacket
+ i
- 1);
2469 * Same as above, just without comments
2472 for (i
= 0, start
= last
= -2; i
< rxa
->nAcks
; i
++)
2473 if (rxa
->acks
[i
] == RX_ACK_TYPE_NACK
) {
2475 printf(" nacked %d",
2476 rxa
->firstPacket
+ i
);
2478 } else if (last
!= i
- 1) {
2479 printf(",%d", rxa
->firstPacket
+ i
);
2483 } else if (last
== i
- 1 && start
!= last
)
2484 printf("-%d", rxa
->firstPacket
+ i
- 1);
2486 if (last
== i
- 1 && start
!= last
)
2487 printf("-%d", rxa
->firstPacket
+ i
- 1);
2494 * These are optional fields; depending on your version of AFS,
2495 * you may or may not see them
2498 #define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
2514 printf(" maxpackets");